Table of Contents
Logging in SOLoist projects
log4j library is used as a logging utility for SOLoist projects. log4j.jar file is placed in war/lib folder in EmptyProject. You can always download the latest version of log4j from Apache log4j Website.
log4j Configuration
To configure log4j for SOLoist project you have to change log4j.xml file. log4j.xml is part of EmptyProject. You have to set path to log file on your file system and logging level. More about configuration of log4j.xml you can read on Apache Logging Wiki.
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender"> <param name="file" value="d:/temp/repository/out.log"></param> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %d{ABSOLUTE} - %m%n"></param> </layout> </appender>
In param tag for attribute value set log file's path on the file system.
On Windows
<param name="file" value="d:/temp/repository/out.log"></param>
On Linux
<param name="file" value="/home/user/soloist/repository/out.log"></param>
Complete log4j.xml Example
Below is the complete log4j.xml from the Empty Project.
- log4j.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %d{ABSOLUTE} - %m%n" /> </layout> </appender> <appender name="file" class="org.apache.log4j.DailyRollingFileAppender"> <param name="file" value="d:/temp/repository/out.log"></param> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %d{ABSOLUTE} - %m%n"></param> </layout> </appender> <logger name="rs.sol.soloist"> <level value="info" /> </logger> <root> <priority value="info" /> <appender-ref ref="file" /> <appender-ref ref="console" /> </root> </log4j:configuration>