Solved

log4j log4j.appender.R.MaxBackupIndex

Posted on 2010-08-19
7
1,529 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running JavaFX on JDeveloper 12C 1 76
Crystal Reports Licensing Questions 4 59
Java syntax, or is it Selenium 6 37
restrict decimal places for double datatype 10 29
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video teaches viewers about errors in exception handling.
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.

740 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