Example two: Surveillance log

Log entries of the class Surveillance are described under the System category - see System. If no other logging is configured with log4j, all logging will be done in the System category.

Alternatively a separate log file could be used for the surveillance log. To do this, you may configure log4j in the following way:

<appender name="SL" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
<param name="File" value="${jboss.server.home.dir}/log/surveillance.log" />
<param name="Append" value="false" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="BufferedIO" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
</layout>
</appender>

<logger name="dme.base.log" additivity="false">
<priority value="ALL" />
<appender-ref ref="SL" />
</logger>

Here, the appender is given the name SL. It outputs all (priority value="ALL") messages of the class dme.base.log to the file surveillance.log.

Note that the class dme.base.log may include entries that are not of the Surveillance type. If you want to ensure that only log entries that have been created by the surveillance log are included, you must create three similar loggers for the SL appender, with the following names:

-instead of the dme.base.log logger.

Next topic

Settings and log output