logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1232) Incorrect log rotation in last week of year
Date Tue, 05 Jan 2016 00:48:39 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15082116#comment-15082116
] 

Gary Gregory commented on LOG4J2-1232:
--------------------------------------

If what you had in mind is something like:

{noformat}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
index fbc74b4..7ec8eca 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/PatternProcessor.java
@@ -99,6 +99,7 @@
         final Calendar cal = Calendar.getInstance();
         cal.set(currentCal.get(Calendar.YEAR), 0, 1, 0, 0, 0);
         cal.set(Calendar.MILLISECOND, 0);
+        cal.setMinimalDaysInFirstWeek(1);
         if (frequency == RolloverFrequency.ANNUALLY) {
             increment(cal, Calendar.YEAR, increment, modulus);
             nextTime = cal.getTimeInMillis();
{noformat}

That does not work. Please see the unit test {{org.apache.logging.log4j.core.appender.rolling.PatternProcessorTest}}
that is annotated with {{@Ignored}}.

> Incorrect log rotation in last week of year
> -------------------------------------------
>
>                 Key: LOG4J2-1232
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1232
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.3, 2.5
>            Reporter: Nikolai
>            Priority: Critical
>
> I have log4j2.xml configuration with several log-files definitions like:
> {code:xml}
> <RollingRandomAccessFile name="FIX_MESSAGES_FILE_MARKET_DATA" fileName="logs/market_data_msg.log"
>                          filePattern="logs/market_data_msg.log-%d{yyyy-MM-'W'W}" immediateFlush="false">
>   <PatternLayout pattern="%m%n"/>
>   <Policies>
>     <TimeBasedTriggeringPolicy/>
>   </Policies>
> </RollingRandomAccessFile>
> {code}
> Today (2015-12-28) all log files suddenly become almost empty. Reason in permanent rotation
current log file in file "market_data_msg.log-2014-12-W5" (wrong year). As result of permanent
rotation both files contains only 0 or 1 lines and information is lost!
> Obviously, the problem related with the fact that today started last week of the year.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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


Mime
View raw message