Solved

log4j log4j.appender.R.MaxBackupIndex

Posted on 2010-08-19
7
1,458 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
Comment Utility
Try setting it to Integer.MAX_VALUE
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
(which is 2,147,483,647 fyi)
0
 

Author Comment

by:cgray1223
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 92

Expert Comment

by:objects
Comment Utility
> 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
Comment Utility
>> 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
Comment Utility
>> 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
Comment Utility
>>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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

763 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

7 Experts available now in Live!

Get 1:1 Help Now