JBoss Community Archive (Read Only)

JBoss AS 7.1

How To

How to in CLI:

How do I add a log category?


How do I change a log level?

To change a handlers log level:


Changing the level on a log category is the same:


How do I log my applications messages to their own file?

  1. Create a file handler. There are 3 different types of file handlers to choose from; file-handler, periodic-rotating-file-handler and size-rotating-file-handler. In this example we'll just use a simple file-handler.

    /subsystem=logging/file-handler=fh:add(level=INFO, file={"relative-to"=>"jboss.server.log.dir", "path"=>"fh.log"}, append=false, autoflush=true)
  2. Now create the log category.


How do I use log4j.properties or log4j.xml instead of using the logging subsystem configuration?

First note that if you choose to use a log4j configuration file, you will no longer be able to change the log4j logging configuration at runtime.

  1. Create a jboss-deployment-structure.xml with the following content and place it in the META-INF/ directory if you are deploying an EAR or in either the META-INF/ or WEB-INF/ directory if you are deploying a WAR.

    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
            <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
                <module name="org.apache.log4j" />
  2. Include the log4j.properties or log4j.xml file in the lib/ directory in your deployment.

  3. Deploy your application.

How to in XML:

How do I log my applications messages to their own file?

<subsystem xmlns="urn:jboss:domain:logging:1.1">
  <file-handler name="fh">
    <level name="INFO"/>
    <file relative-to="jboss.server.log.dir" path="fh.log"/>
    <autoflush value="true"/>
    <append value="false"/>
  <logger category="com.your.company" use-parent-handlers="false">
      <handler name="fh"/>
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:22:05 UTC, last content change 2013-02-21 17:08:24 UTC.