Solved

log4j log4j.appender.R.MaxBackupIndex

Posted on 2010-08-19
7
1,476 Views
Last Modified: 2012-08-14
I'm using a org.apache.log4j.RollingFileAppender in order to process and store my log statements and I'm wondering how to get it to never overwrite the output log file?  I left off the log4j.appender.R.MaxBackupIndex configuration and it seems to make one copy then overwrite the original.  Maybelog4j.appender.R.MaxBackupIndex=999999?

0
Comment
Question by:cgray1223
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 33478903
Try setting it to Integer.MAX_VALUE
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33478919
(which is 2,147,483,647 fyi)
0
 

Author Comment

by:cgray1223
ID: 33480107
I'm testing locally with a max file size of 1KB so I should get a ton of backups... test.log.1, test.log.2...etc.  For some reason the test.log file remains at 1KB, the test.log.1 gets created but grows past the 1KB max that I specified in my config (see below).  Any ideas?


.# The logging properties used for IDE based testing, we want to see
# debug output on the console (use out in that case).
# log4j.rootLogger=INFO, out
log4j.rootCategory=INFO, out, R

log4j.logger.org.springframework=WARN
log4j.logger.com.logging.test=DEBUG

# CONSOLE appender not used by default
log4j.appender.out=org.apache.log4j.ConsoleAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.out.threshold=DEBUG

# Second appender writes to a file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=c://temp//logs//test.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
# Control the maximum log file size
log4j.appender.R.MaxFileSize=1KB
log4j.appender.R.MaxBackupIndex=Integer.MAX_VALUE
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

by:objects
ID: 33480845
> log4j.appender.R.MaxBackupIndex=Integer.MAX_VALUE

don't do that, try:

log4j.appender.R.MaxBackupIndex=999999
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 33485006
>> I left off the log4j.appender.R.MaxBackupIndex configuration and it seems to make one copy then overwrite the original.
There is one backup file by default.
So try with log4j.appender.R.MaxBackupIndex=999999
0
 
LVL 16

Expert Comment

by:Valeri
ID: 33485071
>> gets created but grows past the 1KB max that I specified in my config
what exactly do you mean?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33485512
>>log4j.appender.R.MaxBackupIndex=Integer.MAX_VALUE

No - i didn't mean to put that directly in the config file. You need to use the literal value
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Groovy:unable to resolve class error 2 70
printing a file in reverse order is easy in recursion rather than in iteration 3 51
simple java question 3 44
Java Loop 6 49
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now