tags:

views:

227

answers:

1

How in JBoss to write traces to separate file?

I would like to see traces about org.hibernate.SQL and org.hibernate.type in separate trace file.

I added next appender and categories to jboss-log4j.xml but it does not help - jboss still writes traces into server.log.

<appender name="HIBERNATE" class="org.jboss.logging.appender.DailyRollingFileAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
        <param name="File" value="/u1/trace/sql.log"/>
        <param name="Append" value="true"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
        </layout>
</appender>


<category name="org.hibernate.SQL">
      <priority value="DEBUG"/>
      <appender-ref ref="HIBERNATE" />
</category>

<category name="org.hibernate.type">
      <priority value="TRACE"/>
      <appender-ref ref="HIBERNATE" />
</category>
+2  A: 

Adding appenders to a category is "additive" meaning that the new appender is logged to in addition to the existing root appender. You need to explicitly stop it from doing that:

<category name="org.hibernate.SQL">
      <priority value="DEBUG"/>
      <appender-ref ref="HIBERNATE" additivity="false"/>
</category>
skaffman