21 Dec 2014

JBoss Logging Configuration

In JBoss, the logging subsystem represents the overall server logging configuration and it has 3 parts - handler configurations, logger and the root logger declarations. Each logger will reference a handler or a set of handlers and each handler declares the log format and output.

Inside Jboss standalone.xml (../standalone/configuration/standalone.xml), place the following code between <profile> tags.
<profile>
   <subsystem xmlns="urn:jboss:domain:logging:1.0">
      <console-handler name="CONSOLE" autoflush="true">
         <level name="DEBUG"/>
         <formatter>
            <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
         </formatter>
       </console-handler>

       <periodic-rotating-file-handler name="FILE" autoflush="true">
          <formatter>
             <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
          </formatter>
          <file relative-to="jboss.server.log.dir" path="server.log"/>
          <suffix value=".yyyy-MM-dd"/>
       </periodic-rotating-file-handler>

       <logger category="com.arjuna">
          <level name="WARN"/>
       </logger>

       <root-logger>
          <level name="DEBUG"/>
          <handlers>
              <handler name="CONSOLE"/>
              <handler name="FILE"/>
          </handlers>
       </root-logger>
   </subsystem>
</profile>
JBoss Logging Configuration

In the proceeding lines of configuration:
  1. console-handler: It defines a handler which writes log to the console.

  2. periodic-rotating-file-handler: It defines a handler which writes to a file, and also rotating the log after a time period derived from the given suffix string which should be in a format understood by java.text.SimpleDateFormat like,
    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    where %s is the message and %E is the exception if one exists.

  3. logger: It defines a logger category. In this we can define the log level specifying which message levels will be logged by it.
    Note: Message levels lower than the specified level will be discarded.

  4. root-logger: It defines the root logger for this log context. Here also we can define the log level specifying which message levels will be logged by it.
    Note: Message levels lower than the specified level will be discarded.

Related Posts:

     Installing JBoss Application Server in Windows

     Starting and Stopping JBoss Application Server

     Deployment Scanner in JBoss





Popular Posts

Write to Us
Name
Email
Message