Results 1 to 3 of 3
- 01-11-2011, 06:38 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 5
- Rep Power
- 0
log4j RollingFileAppender question
Hello,
I have a log4j property setting like this:
log4j.appender.fai=org.apache.log4j.RollingFileApp ender
log4j.appender.fai.file=/opt/wasprofile/appsrv/logs/fai/fai.log
log4j.appender.fai.append=true
log4j.appender.fai.layout=org.apache.log4j.Pattern Layout
log4j.appender.fai.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
log4j.appender.fai.MaxFileSize=2MB
log4j.appender.fai.fileNamePattern=fai%i.log
log4j.appender.fai.MaxBackupIndex=4
Initially an fai.log is created when the server starts up. When this log reaches 2MB, it gets rolled over to fai.log.1 and fai.log starts logging the latest statements as expected. When fai.log reaches 2MB the next time, it's content gets rolled over to fai.log.1, whose contents in turn get rolled over to fai.log.2. This goes on.....
So at any point of time, I see the following logs in my system:
fai.log
fai.log.1
fai.log.2
fai.log.3
fai.log.4
All this works perfectly for a while. Then all of a sudden, the 4 backup files get archived as the following four files for some reason:
fai-log.1-2011-01-11.log
fai-log.2-2011-01-11.log
fai-log.3-2011-01-11.log
fai-log.4-2011-01-11.log
The next time fai.log gets to 2MB, it rolls over the contents to a new fai.log.1. This goes on fine again. So now I have the following files in the system:
fai.log
fai.log.1
fai.log.2
fai.log.3
fai.log.4
fai-log.1-2011-01-11.log
fai-log.2-2011-01-11.log
fai-log.3-2011-01-11.log
fai-log.4-2011-01-11.log
Again, a new set of archive files are created after a while. So eventually, my system runs out of disk space. How do I prevent the archiving process from happening?
My application is running on a WAS 6.1 server that is hosted in a zLinux machine. Is this environment related?
thanks.
- 01-12-2011, 03:01 AM #2
its as if something is sometimes invoking the TimeBasedRollingPolicy
which might be the default if not specified in your log4j configs.
Maybe add a
log4j.appender.fai.rollingPolicy=FixedWindowRollin gPolicy
to enforce the fixed roling of max file size as you want.
- 01-12-2011, 04:38 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 5
- Rep Power
- 0
Thanks for the suggestion. I tried that and it still doesn't work. This is the modified properties file:
log4j.appender.fai=org.apache.log4j.RollingFileApp ender
log4j.appender.fai.file=/opt/wasprofile/appsrv/logs/fai/fai.log
log4j.appender.fai.rollingPolicy=FixedWindowRollin gPolicy
log4j.appender.fai.append=true
log4j.appender.fai.layout=org.apache.log4j.Pattern Layout
log4j.appender.fai.layout.ConversionPattern=%x %p %d{ISO8601} - %m%n
log4j.appender.fai.MaxFileSize=2MB
log4j.appender.fai.MaxBackupIndex=4
Any other suggestions?
Similar Threads
-
log4j RollingFileAppender question
By vasanthj in forum Advanced JavaReplies: 0Last Post: 12-07-2010, 08:07 PM -
Log4J Question <moved>
By razorSpirit in forum New To JavaReplies: 2Last Post: 10-13-2010, 10:33 PM -
log4j RollingFileAppender missing files
By razorSpirit in forum New To JavaReplies: 0Last Post: 10-13-2010, 06:57 PM -
Problem on Log4j: How to include custom <filter/> into JBoss (log4j.xml)?
By holyjohn in forum Advanced JavaReplies: 1Last Post: 09-20-2010, 08:32 AM -
log4j
By swapna_d in forum New To JavaReplies: 7Last Post: 08-04-2010, 12:23 AM
Bookmarks