?
Solved

log4j log4j.appender.R.MaxBackupIndex

Posted on 2010-08-19
7
Medium Priority
?
1,591 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And 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 2000 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

Independent Software Vendors: 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!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

801 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