Question

Need help with jboss logging.I am new to jboss application server. I am able to start the application server and i do see in the server log that jboss has started. But when i click on the application and surf around the application that i have deployed i dont see any logging and i am wondering why.I have tried doing this in jboss-log4j.xml

  <appender-ref ref="CONSOLE"/>
  <priority value="INFO" />
  <appender-ref ref="FILE"/>
  <priority value="INFO" />

Was it helpful?

Solution

You should create a new appender for your application in log4j.xml:

<appender name="MYAPPENDER" class=""org.jboss.logging.appender.DailyRollingFileAppender">
  <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
  <param name="File" value="${jboss.server.log.dir}/filename.log"/>
  <param name="Threshold" value="DEBUG"/>
  <param name="Append" value="true"/>
  <!-- Rollover at midnight each day -->
  <param name="DatePattern" value="'.'yyyy-MM-dd"/>

  <layout class="org.apache.log4j.PatternLayout">
     <!-- The default pattern: Date Priority [Category] Message\n -->
     <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

     <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
     <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
      -->
  </layout>

And then specify a category after it:

<category name="com.my.package" additivity="false">
  <priority value="DEBUG" />
  <appender-ref ref="MYAPPENDER"/>
</category>

Where com.my.package is the (top level) package of your application. All classes in this package and its sub-packages will be logged to MYAPPENDER.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top