Solved

log4j log4j.appender.R.MaxBackupIndex

Posted on 2010-08-19
7
1,512 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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
ForLoop Example 3 52
type mismatch (Object[] to double[] 4 33
hibernate example for saving data 19 52
ejb wildfly example 2 20
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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.

840 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