DailyRollingFileAppender and log4j.xml

Discussion in 'Java' started by David, Sep 27, 2004.

  1. David

    David Guest

    I am trying to use the DailyRollingFileAppender for a daily log file.
    I am unable to find any examples using the log4j.xml configuration
    (does everyone use properties files?!) so I would really appreciate
    any help you can give me.

    I have the following defined in log4j.xml and it works great as a log
    file appender:
    <appender name="SyslogInfoLogFile"
    class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="/info.log"/>
    <param name="MaxFileSize" value="1000000KB"/>
    <param name="MaxBackupIndex" value="10"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %-5p
    %c{2} - %m%n"/>
    </layout>
    </appender>


    But when I try to change it into a DailyRollingFileAppender I don't
    get the info.log file:

    <appender name="SyslogInfoLogFile"
    class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="/info.log"/>
    <param name="Append" value="true"/>
    <param name="DatePattern" value="'.'yyyy-MM-dd-HH-mm"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %-5p
    %c{2} - %m%n"/>
    </layout>
    </appender>



    I just don't see why this is failing, could somebody please see what
    is wrong?
    David, Sep 27, 2004
    #1
    1. Advertising

  2. David

    vimleshmangalmishra

    Joined:
    May 1, 2007
    Messages:
    1
    log4j-DailyRollingFileAppender

    Hello David

    Try this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "/WEB-INF/log4j.dtd">

    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">

    <appender name="DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="../webapps/WebCatStruts/WEB-INF/log/LifeCare_WebCat.log" />
    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    <param name="Append" value="true"/>
    <param name="Threshold" value="DEBUG"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{HH:mm:ss:SSS} - %p - %C{1} - %m%n"/>
    </layout>
    </appender>

    <root>
    <appender-ref ref="DEBUG"/>
    </root>
    </log4j:configuration>


    vimleshmangalmishra, May 1, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Seb
    Replies:
    0
    Views:
    3,395
  2. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,751
    Alexandra Stehman
    Jan 19, 2004
  3. Replies:
    0
    Views:
    1,702
  4. Replies:
    0
    Views:
    834
  5. Replies:
    1
    Views:
    877
    Oliver Wong
    Jul 10, 2006
Loading...

Share This Page