You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by bu...@apache.org on 2011/12/28 09:05:07 UTC

DO NOT REPLY [Bug 52392] New: Issue with DailyRollingFileAppender

https://issues.apache.org/bugzilla/show_bug.cgi?id=52392

             Bug #: 52392
           Summary: Issue with DailyRollingFileAppender
           Product: Log4j
           Version: 1.2
          Platform: PC
        OS/Version: AIX
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Appender
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: suigion.anderson@gmail.com
    Classification: Unclassified


Hi,

I am encountered the following issue in log4j-1.2.8.jar

I am using DailyRollingFileAppender in my application. What I want to achieve
is my log file will be rolled every day on midnight. As my application will not
run 24hours, will the log file rolled at 00:00:00? It seems that it is not. It
only rolled over the next morning when I access my application. But the strange
thing is after it is rolled over, log4j sill write into the yesterday's log
file. For example:
MyApps.log   --> today's log file
MyApps.log.2011-12-10 --> yesterday's log file, contain 2011-12-09 logs

The application is still writing into MyApps.log.2011-12-10 and MyApps.log. The
correct way should write only into MyApps.log. Do you have idea how to fix
this? 

So, on 2011-12-10, MyApps.log.2011-12-10 contain the 2011-12-10 logs, not
2011-12-09 logs. (funny)
But when the next day come, I can see MyApps.log.2011-12-10 contain the
2011-12-09 logs, which is what I want.

Below is my 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="MyAppender1"
class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value"/logs/MyApps.log" />
    <param name="Append" value="true" />
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout"> 
        </layout> 
     </appender> 

    <logger name=="mypackage.myapp1" additivity="false">
        <level value="DEBUG" />
        <appender-ref ref="MyAppender1" />
    </logger>

    <logger name="mypackage.myapp2" additivity="false">
        <level value="DEBUG" />
        <appender-ref ref="MyAppender1" />
    </logger>

</log4j:configuration>

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org