Question


Accenture
US
Last activity: 28 Jul 2016 6:29 EDT
Log Rotation with DailySizeRollingFileAppenderPega
Hello,
I am working on rotating my log files from within Pega based on Time and Size with the DailySizeRollingFileAppender in Pega 7.1.9. The application is running on JBoss EAP 6.4.4 on RHEL 6.
The time based portion of the appender seems to be working fine, but I am trying to also rotate based on the 'MaxFileSize' parameter. I lowered the value to 250KB for testing, but the log file is still being written to after the log size is met. Am I misinterpreting how the appender should work? or is something wrong with the syntax below? the $pega.log.location is a variable that I am passing via JAVA_OPTIONS
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'${pega.log.location}/test_file-'yyyy-MM-dd-a'.log'"/>
<param name="MaxFileSize" value="50MB" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
</appender>
Thanks,
Jeff
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution


This is a bug, we are planning to address this issue as part of ' BUG-233954 : CE - Appending to existing Log though the MaxFileSize is reached' in PRPC 7.2.1.


Pegasystems Inc.
US
first check if without substitution, does the appender work (use hard-coded path)? I don't believe you can simply pass in an jvm argument for that. I see the default (web.tmpdir) substitution had to be set in the java code.


Accenture
US
The initial log file is created, and is rotated at noon and midnight, but is not also being rotated if the MaxFileSize is reached prior to the time rotation. I have updated the appender to what is listed below, and the file still grows past the 250KB test size I have it configured to right now.
ls -lah test_file-2016-02-08*
-rw-r--r--. 1 jboss-as jboss 3.1M Feb 8 12:20 test_file-2016-02-08-AM.log
-rw-r--r--. 1 jboss-as jboss 1.4M Feb 8 16:07 test_file-2016-02-08-PM.log
Appender:
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/nics/jboss/EAP-6.4.0/standalone/log/test_file-'yyyy-MM-dd-a'.log'"/>
<param name="MaxFileSize" value="250KB" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
To get the appender to write to $pega.log.location (how it was set previously), I set the variable in /etc/jboss-as/jboss-as.conf and added it to the _JAVA_OPTIONS environment variable:
Here is the snippet from the /etc/jboss-as/jboss-as.conf file:
pega_log_dir=/nics/jboss/EAP-6.4.0/standalone/log
export _JAVA_OPTIONS="-Dpega.log.location=$pega_log_dir


Pegasystems Inc.
US
I see, so the substitution of $pega_log_dir does work? Can you also add (specify whatever number of files to be backed up)
<param name="MaxBackupIndex" value="5" />
and report back if the behavior changes?


Accenture
US
I have isolated down the problem to the -a option in the FileNamePattern 'yyyy-MM-dd-a'
The log files successfully rotate without any date:
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/test/jboss/EAP-6.4.0/standalone/log/test_file.log'"/>
<param name="MaxFileSize" value="250KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
</appender>
ls -lah test_file*
-rw-r--r--. 1 jboss-as jboss 58K Feb 9 11:45 test_file.log
-rw-r--r--. 1 jboss-as jboss 254K Feb 9 11:45 test_file.log.1
The log files successfully rotate with the date set as 'yyyy-MM-dd':
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/test/jboss/EAP-6.4.0/standalone/log/test_file-'yyyy-MM-dd'.log'"/>
<param name="MaxFileSize" value="250KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="com.pega.apache.log4j.PatternLayout">
I have isolated down the problem to the -a option in the FileNamePattern 'yyyy-MM-dd-a'
The log files successfully rotate without any date:
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/test/jboss/EAP-6.4.0/standalone/log/test_file.log'"/>
<param name="MaxFileSize" value="250KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
</appender>
ls -lah test_file*
-rw-r--r--. 1 jboss-as jboss 58K Feb 9 11:45 test_file.log
-rw-r--r--. 1 jboss-as jboss 254K Feb 9 11:45 test_file.log.1
The log files successfully rotate with the date set as 'yyyy-MM-dd':
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/test/jboss/EAP-6.4.0/standalone/log/test_file-'yyyy-MM-dd'.log'"/>
<param name="MaxFileSize" value="250KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
</appender>
ls -lah test_file-2016-02-09*
-rw-r--r--. 1 jboss-as jboss 83K Feb 9 11:50 test_file-2016-02-09.log
-rw-r--r--. 1 jboss-as jboss 253K Feb 9 11:50 test_file-2016-02-09.log.1
-rw-r--r--. 1 jboss-as jboss 253K Feb 9 11:50 test_file-2016-02-09.log.2
-rw-r--r--. 1 jboss-as jboss 255K Feb 9 11:50 test_file-2016-02-09.log.3
-rw-r--r--. 1 jboss-as jboss 254K Feb 9 11:50 test_file-2016-02-09.log.4
-rw-r--r--. 1 jboss-as jboss 253K Feb 9 11:49 test_file-2016-02-09.log.5
However, the log files do not rotate with the date set as 'yyyy-MM-dd-a':
<appender name="test_file" class="com.pega.pegarules.priv.util.DailySizeRollingFileAppenderPega">
<param name="FileNamePattern" value="'/test/jboss/EAP-6.4.0/standalone/log/test_file-'yyyy-MM-dd-a'.log'"/>
<param name="MaxFileSize" value="250KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="com.pega.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c- %m%n"/>
</layout>
</appender>
ls -lah test_file-2016-02-09*[AP]M*
-rw-r--r--. 1 jboss-as jboss 1.1M Feb 9 11:55 test_file-2016-02-09-AM.log
Is this a bug with the appender? Do you have any suggestions? The rotation is more time sensitive. I would rather use 'yyyy-MM-dd-a' with the DailyRollingFileAppenderPega appender (and no MaxFileSize) than use MaxFileSize and the DailySizeRollingFileAppenderPega.


Pegasystems Inc.
US
Thanks for sharing the findings. From the code, it does seem that only 'yyyy-MM-dd' is supported. But I am not 100% sure if this is a bug or enhancement request. ChaithanyaKumar Cholleti, can you provide your insights when you get a chance?
Accepted Solution


This is a bug, we are planning to address this issue as part of ' BUG-233954 : CE - Appending to existing Log though the MaxFileSize is reached' in PRPC 7.2.1.


Cognizant
IN
If this is resolved in PRPC 7.2.1 then it should have been listed here...
http://pdn.pega.com/resolved-issues?field_product_version_tid=16721&field_sr_value=&field_issue_value=&title=&body_value=&field_product_topic_category_tid=146
however we are not finding any information about DailySizeRollingFileAppenderPega in this list.