16.2. Configuration
If you're using JBoss Enterprise Application Server or wildFly, just add the following configuration to the logging subsystem:
<!-- A file handler for PicketLink logging messages --> <periodic-rotating-file-handler name="PICKETLINK"> <file relative-to="jboss.server.log.dir" path="picketlink.log"/> <suffix value=".yyyy-MM-dd"/> <append value="true"/> </periodic-rotating-file-handler> <!-- This should enable logging for all PicketLink modules in use by your application --> <logger category="org.picketlink"> <level name="DEBUG"/> <handlers> <handler name="PICKETLINK"/> </handlers> </logger>
The configuration above is very useful if you want to have a specific logging file for all PicketLink logging messages.
However, if you want to enable logging regardless the application server in use, you must have a log4j.xml file in your classpath as follows:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <!-- ============================== --> <!-- Append messages to the file --> <!-- ============================== --> <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="${basedir}/target/test.log"/> <param name="Append" value="true"/> <param name="DatePattern" value="'.'yyyy-MM-dd"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c] %m%n"/> </layout> </appender> <!-- ============================== --> <!-- Append messages to the console --> <!-- ============================== --> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c] %m%n"/> </layout> </appender> <!-- ================ --> <!-- Limit categories --> <!-- ================ --> <!-- PicketLink Root category. --> <category name="org.picketlink"> <priority value="DEBUG"/> </category> <!-- ======================= --> <!-- Setup the Root category --> <!-- ======================= --> <root> <appender-ref ref="CONSOLE"/> <appender-ref ref="FILE"/> </root> </log4j:configuration>
You must also add the following dependency to your project:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.0</version> </dependency>