Discussion:
[jira] [Created] (LOG4J2-550) TimeBasedTriggeringPolicy is not triggering file roll-over
Bohdan Mushkevych (JIRA)
2014-02-24 20:24:20 UTC
Permalink
Bohdan Mushkevych created LOG4J2-550:
----------------------------------------

Summary: TimeBasedTriggeringPolicy is not triggering file roll-over
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml

I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.

Attached log4j2.xml configuration meant to:
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern

Whenever JVM is restarted, log4j abandons "old" files un-archived:

-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log




--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bohdan Mushkevych (JIRA)
2014-02-24 20:24:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bohdan Mushkevych updated LOG4J2-550:
-------------------------------------

Attachment: log4j2.xml
Post by Bohdan Mushkevych (JIRA)
TimeBasedTriggeringPolicy is not triggering file roll-over
----------------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bohdan Mushkevych (JIRA)
2014-02-24 20:28:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bohdan Mushkevych updated LOG4J2-550:
-------------------------------------

Summary: .log files are left un-archived after JVM restart (was: TimeBasedTriggeringPolicy is not triggering file roll-over)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bohdan Mushkevych (JIRA)
2014-02-24 20:34:28 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bohdan Mushkevych updated LOG4J2-550:
-------------------------------------

Description:
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.

Attached log4j2.xml configuration meant to:
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern

Whenever JVM is restarted, log4j abandons "old" files un-archived:

-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log

Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after

was:
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.

Attached log4j2.xml configuration meant to:
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern

Whenever JVM is restarted, log4j abandons "old" files un-archived:

-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bohdan Mushkevych (JIRA)
2014-03-24 17:40:48 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945401#comment-13945401 ]

Bohdan Mushkevych edited comment on LOG4J2-550 at 3/24/14 5:40 PM:
-------------------------------------------------------------------

I believe this issue is caused by overlapping of two factors:
- all .log file names are dynamic (driven by ${sd::type} value)
Hence - log4j2 could not track them explicitly, and when the JVM is restarted - old .log files are left unaccounted.
- using ${date:yyyyMMdd} in the filename pattern
In contrary to %d{yyyyMMdd} it seams to be static and computed only once - at the JVM startup

To address both issues I came up with the following .xml file:

{code:xml}
<Properties>
<Property name="routing_filename">${log.path}/table-$${sd:type}.log</Property>
</Properties>

<Routing name="Routing">
<Routes pattern="$${sd:type}">
<Route>
<RollingFile name="RollingFile-${sd:type}"
fileName="${routing_filename}"
filePattern="${log.path}/%d{yyyyMMdd}/%d{yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">
<PatternLayout>
<!-- %K{v} stands for the message passed in StructuredDataMessage map with key "v" -->
<!-- %n stands for new line -->
<Pattern>%d{yyyyMMddHH},%K{v}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="64 MB"/>
</Policies>
<DefaultRolloverStrategy max="999"/>
</RollingFile>
</Route>
</Routes>
</Routing>
{code}


was (Author: mushkevych):
I believe this issue is caused by overlapping of two factors:
- all .log file names are dynamic (driven by ${sd::type} value)
Hence - log4j2 could not track them explicitly, and when the JVM is restarted - old .log files are left unaccounted.
- using ${date:yyyyMMdd} in the filename pattern
In contrary to %d{yyyyMMdd} it seams to be static and computed only once - at the JVM startup

To address both issues I came up with the following .xml file:
<Properties>
<Property name="routing_filename">${log.path}/table-$${sd:type}.log</Property>
</Properties>

<Routing name="Routing">
<Routes pattern="$${sd:type}">
<Route>
<RollingFile name="RollingFile-${sd:type}"
fileName="${routing_filename}"
filePattern="${log.path}/%d{yyyyMMdd}/%d{yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">
<PatternLayout>
<!-- %K{v} stands for the message passed in StructuredDataMessage map with key "v" -->
<!-- %n stands for new line -->
<Pattern>%d{yyyyMMddHH},%K{v}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="64 MB"/>
</Policies>
<DefaultRolloverStrategy max="999"/>
</RollingFile>
</Route>
</Routes>
</Routing>
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bohdan Mushkevych (JIRA)
2014-03-24 17:40:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945401#comment-13945401 ]

Bohdan Mushkevych commented on LOG4J2-550:
------------------------------------------

I believe this issue is caused by overlapping of two factors:
- all .log file names are dynamic (driven by ${sd::type} value)
Hence - log4j2 could not track them explicitly, and when the JVM is restarted - old .log files are left unaccounted.
- using ${date:yyyyMMdd} in the filename pattern
In contrary to %d{yyyyMMdd} it seams to be static and computed only once - at the JVM startup

To address both issues I came up with the following .xml file:
<Properties>
<Property name="routing_filename">${log.path}/table-$${sd:type}.log</Property>
</Properties>

<Routing name="Routing">
<Routes pattern="$${sd:type}">
<Route>
<RollingFile name="RollingFile-${sd:type}"
fileName="${routing_filename}"
filePattern="${log.path}/%d{yyyyMMdd}/%d{yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">
<PatternLayout>
<!-- %K{v} stands for the message passed in StructuredDataMessage map with key "v" -->
<!-- %n stands for new line -->
<Pattern>%d{yyyyMMddHH},%K{v}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
<SizeBasedTriggeringPolicy size="64 MB"/>
</Policies>
<DefaultRolloverStrategy max="999"/>
</RollingFile>
</Route>
</Routes>
</Routing>
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Ralph Goers (JIRA)
2014-03-24 18:00:49 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945425#comment-13945425 ]

Ralph Goers commented on LOG4J2-550:
------------------------------------

Just as an FYI - $\{date:yyyyMMdd} will be computed when the configuration is processed while $$\{date:yyyyMMdd} will be computed every time the file pattern is resolved. However I doubt that would resolve your issue.
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bohdan Mushkevych (JIRA)
2014-03-24 18:16:44 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945447#comment-13945447 ]

Bohdan Mushkevych commented on LOG4J2-550:
------------------------------------------

Ralph

I have tried using double $$ sign, for instance:

filePattern="${log.path}/$${date:yyyyMMdd}/$${date:yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">

However it only causes exception [1]. Because of this behaviour I have either used single $ or %.

[1] Exception, caused by $${date:yyyyMMdd}

2014-03-24 11:12:22,989 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(max="999", min="null", fileIndex="null", compressionLevel="null", Configuration(RoutingLoggingConfiguration))
2014-03-24 11:12:22,991 ERROR An exception occurred processing Appender Routing java.lang.StringIndexOutOfBoundsException: String index out of range: 95
at java.lang.String.<init>(String.java:201)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:816)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:737)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.replace(StrSubstitutor.java:306)
at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:792)
at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:667)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.createAppender(RoutingAppender.java:153)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.getControl(RoutingAppender.java:137)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.append(RoutingAppender.java:111)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
at org.apache.logging.log4j.core.Logger.log(Logger.java:112)
at org.apache.logging.log4j.spi.AbstractLoggerWrapper.log(AbstractLoggerWrapper.java:121)
at org.apache.logging.log4j.EventLogger.logEvent(EventLogger.java:56)
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bohdan Mushkevych (JIRA)
2014-03-24 18:16:44 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945447#comment-13945447 ]

Bohdan Mushkevych edited comment on LOG4J2-550 at 3/24/14 6:15 PM:
-------------------------------------------------------------------

Ralph

I have tried using double $$ sign, for instance:

{code}
filePattern="${log.path}/$${date:yyyyMMdd}/$${date:yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">
{code}

However it only causes exception [1]. Because of this behaviour I have either used single $ or %.

[1] Exception, caused by $${date:yyyyMMdd}

2014-03-24 11:12:22,989 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(max="999", min="null", fileIndex="null", compressionLevel="null", Configuration(RoutingLoggingConfiguration))
2014-03-24 11:12:22,991 ERROR An exception occurred processing Appender Routing java.lang.StringIndexOutOfBoundsException: String index out of range: 95
at java.lang.String.<init>(String.java:201)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:816)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:737)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.replace(StrSubstitutor.java:306)
at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:792)
at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:667)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.createAppender(RoutingAppender.java:153)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.getControl(RoutingAppender.java:137)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.append(RoutingAppender.java:111)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
at org.apache.logging.log4j.core.Logger.log(Logger.java:112)
at org.apache.logging.log4j.spi.AbstractLoggerWrapper.log(AbstractLoggerWrapper.java:121)
at org.apache.logging.log4j.EventLogger.logEvent(EventLogger.java:56)



was (Author: mushkevych):
Ralph

I have tried using double $$ sign, for instance:

filePattern="${log.path}/$${date:yyyyMMdd}/$${date:yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz">

However it only causes exception [1]. Because of this behaviour I have either used single $ or %.

[1] Exception, caused by $${date:yyyyMMdd}

2014-03-24 11:12:22,989 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(max="999", min="null", fileIndex="null", compressionLevel="null", Configuration(RoutingLoggingConfiguration))
2014-03-24 11:12:22,991 ERROR An exception occurred processing Appender Routing java.lang.StringIndexOutOfBoundsException: String index out of range: 95
at java.lang.String.<init>(String.java:201)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:816)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:737)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.replace(StrSubstitutor.java:306)
at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:792)
at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:667)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.createAppender(RoutingAppender.java:153)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.getControl(RoutingAppender.java:137)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.append(RoutingAppender.java:111)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
at org.apache.logging.log4j.core.Logger.log(Logger.java:112)
at org.apache.logging.log4j.spi.AbstractLoggerWrapper.log(AbstractLoggerWrapper.java:121)
at org.apache.logging.log4j.EventLogger.logEvent(EventLogger.java:56)
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Ralph Goers (JIRA)
2014-03-24 18:24:46 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945472#comment-13945472 ]

Ralph Goers commented on LOG4J2-550:
------------------------------------

That is because you have two date Lookups and no date conversion. You have to have one %d to control the time the file rollover will occur. All other date references should be lookups with the doulble '$' to cause the date to be resolved every time the pattern is calculated.
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bohdan Mushkevych (JIRA)
2014-03-24 18:32:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13945488#comment-13945488 ]

Bohdan Mushkevych commented on LOG4J2-550:
------------------------------------------

Ralph, that you for explanation.
It would be great should your post above be incorporated into log4j2 documentation.

At the same time, I have just tried that simplier form is also causing the issue:
{code} filePattern="${log.path}/$${date:yyyyMMdd}/%d{yyyyMMddHH}-${sd:type}-${hostName}.%i.log.gz" {code}

2014-03-24 11:18:53,673 DEBUG Calling createStrategy on class org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy for element DefaultRolloverStrategy with params(max="999", min="null", fileIndex="null", compressionLevel="null", Configuration(RoutingLoggingConfiguration))
2014-03-24 11:18:53,675 ERROR An exception occurred processing Appender Routing java.lang.StringIndexOutOfBoundsException: String index out of range: 90
at java.lang.String.<init>(String.java:201)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:816)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.substitute(StrSubstitutor.java:737)
at org.apache.logging.log4j.core.lookup.StrSubstitutor.replace(StrSubstitutor.java:306)
at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:792)
at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:667)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.createAppender(RoutingAppender.java:153)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.getControl(RoutingAppender.java:137)
at org.apache.logging.log4j.core.appender.routing.RoutingAppender.append(RoutingAppender.java:111)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
at org.apache.logging.log4j.core.Logger.log(Logger.java:112)
at org.apache.logging.log4j.spi.AbstractLoggerWrapper.log(AbstractLoggerWrapper.java:121)
at org.apache.logging.log4j.EventLogger.logEvent(EventLogger.java:56)

Perhaps this is driven by a complex appender structure: Appenders -> Routing -> Routes -> Route -> RollingFile ?
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-06-20 04:43:24 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma updated LOG4J2-550:
-------------------------------

Labels: Rollover (was: )
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Labels: Rollover
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bohdan Mushkevych (JIRA)
2014-09-08 20:35:29 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bohdan Mushkevych resolved LOG4J2-550.
--------------------------------------
Resolution: Fixed

issue was resolved accordingly to the above comments. in short - it was more of configuration and learning curve issue.
Post by Bohdan Mushkevych (JIRA)
.log files are left un-archived after JVM restart
-------------------------------------------------
Key: LOG4J2-550
URL: https://issues.apache.org/jira/browse/LOG4J2-550
Project: Log4j 2
Issue Type: Bug
Components: Core
Affects Versions: 2.0-rc1
Reporter: Bohdan Mushkevych
Labels: Rollover
Attachments: log4j2.xml
I am using log4j 2.0-rc1, StructuredDataMessage and EventLogger to perform dynamic logging.
- rotate log files on hourly basis OR after file reaches 64 MB (whatever comes first)
- archive logs that does not satisfy the file pattern
-rw-r--r--. 1 root root 317625 Feb 24 20:16 2014022419-sim-mdmlocal.mobidia.com.log
-rw-r--r--. 1 root root 3333648 Feb 24 20:20 2014022420-activity-mdmlocal.mobidia.com.log
Listing above shows that file 2014022419-sim-mdmlocal.mobidia.com.log was last touched by the system at 20:16, and should have been archived to .log.gz after restart, which occurred soon after
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...