Technical blog

July 21, 2008

Using Log4j with Maven Jetty plugin

Filed under: java — Tags: , — paawak @ 11:42

No extra configuration is needed. If log4j.xml or log4j.properties is present in the classpath, it is picked up and logs are directed to the specified appender(s). I found http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin#MavenJettyPlugin-Logging overtly complicated and unnecessary. The logs can be redirected to a file by using a suitable appender in log4j.xml:

    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="./target/dmsweb_log_file.log" />
        <param name="Append" value="false" >
        <param name="MaxBackupIndex" value="1" >
        <param name="MaxFileSize" value="500KB" >
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern"
                value="%d [%t] %-5p %c - %m%n">
        </layout>
    </appender>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress