logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MATHEW, MANOJ (AIT)" <mm3...@sbc.com>
Subject RollingFileAppender not backing up file
Date Thu, 14 Aug 2003 16:50:28 GMT
I have a RollingFileAppender set up, but it is not backing up after
maxfilesize of 50kb

Here is my properties file
****************************************************************************
**************
#log4j.rootCategory=DEBUG,dest1,A1
log4j.appender.rootLogger.Append=true
#### Second appender writes to a file
log4j.category.nfcs=info, dest1
log4j.debug=true
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
nfcsfilename=c:/apps/ipt/log/nfcs/nfcs1.log
log4j.appender.dest1.File=${nfcsfilename}
log4j.appender.dest1.Append=true
# Control the maximum log file size
log4j.appender.dest1.MaxFileSize=50KB
# Archive log files (one backup file here)
log4j.appender.dest1.MaxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%-5p (%t) %l %c %d %M(%F:%L).
%x: %m%n

****************************************************************************
*************

Here is the code where I do the settings at the start of my program.
PropertyConfigurator p1 = new PropertyConfigurator();
		p1.configureAndWatch(logPath+"log4j.properties", 5000);
		l =
			((RollingFileAppender) (cat.getLogger("nfcs"))
				.getAppender("dest1"));
				System.out.println("Value of append:"+
l.getAppend());
		l.setAppend(true);		

		PropertySetter ps = new PropertySetter(l);
		ps.setProperty("File", logfile);
		ps.setProperty("Append","true");
		PrintWriter k = new PrintWriter(System.out);
		PropertyPrinter p = new PropertyPrinter(k);
		p.print(k);
		l.rollOver();
		l.activateOptions();
****************************************************************************
**************


For some reason when the log4j system reads it it sets the file append
property back to false
And overwrites the existing file
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: setFile called:
c:/apps/ipt/log/nfcs/nfcs1.log, false ( --this should be true)
But how can I control that.

Even in the write method I do this
public static void writeInfoLog(String s) {
		try {
			if (!l.getAppend()) {
				l.setAppend(true);
				l.activateOptions();
			}

			if (cat.isInfoEnabled()) {
				cat.info(s);
				//cat.log(WRAPPER_FQN, Priority.INFO, s,
null);
			} 
						

		} catch (Exception e) {
			cat.error("In writeLog:" + e.getMessage());
		}
	}

But the getAppend check was futile.

Any suggestions?

Thanks
Manoj Mathew



[8/14/03 11:11:30:661 CDT] 6742bab3 SystemOut     O log4j: Parsing for
[nfcs] with value=[info, dest1].
[8/14/03 11:11:30:661 CDT] 6742bab3 SystemOut     O log4j: Level token is
[info].
[8/14/03 11:11:30:661 CDT] 6742bab3 SystemOut     O log4j: Category nfcs set
to INFO
[8/14/03 11:11:30:661 CDT] 6742bab3 SystemOut     O log4j: Parsing appender
named "dest1".
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Parsing layout
options for "dest1".
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Setting property
[conversionPattern] to [%-5p (%t) %l %c %d %M(%F:%L).  %x: %m%n].
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: End of parsing
for "dest1".
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Setting property
[file] to [c:/apps/ipt/log/nfcs/nfcs1.log].
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Setting property
[maxFileSize] to [50KB].
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Setting property
[maxBackupIndex] to [3].
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Setting property
[append] to [true].
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: setFile called:
c:/apps/ipt/log/nfcs/nfcs1.log, true
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: setFile ended
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Parsed "dest1"
options.
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Handling
log4j.additivity.nfcs=[null]
[8/14/03 11:11:30:677 CDT] 6742bab3 SystemOut     O log4j: Finished
configuring.
[8/14/03 11:11:31:505 CDT]  a75ba9f SystemOut     O log4j: Could not find
root logger information. Is this OK?
[8/14/03 11:11:31:505 CDT]  a75ba9f SystemOut     O log4j: Parsing for
[nfcs] with value=[info, dest1].
[8/14/03 11:11:31:505 CDT]  a75ba9f SystemOut     O log4j: Level token is
[info].
[8/14/03 11:11:31:505 CDT]  a75ba9f SystemOut     O log4j: Category nfcs set
to INFO
[8/14/03 11:11:31:505 CDT]  a75ba9f SystemOut     O log4j: Parsing appender
named "dest1".
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Parsing layout
options for "dest1".
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Setting property
[conversionPattern] to [%-5p (%t) %l %c %d %M(%F:%L).  %x: %m%n].
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: End of parsing
for "dest1".
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Setting property
[file] to [c:/apps/ipt/log/nfcs/nfcs1.log].
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Setting property
[maxFileSize] to [50KB].
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Setting property
[maxBackupIndex] to [3].
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Setting property
[append] to [true].
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: setFile called:
c:/apps/ipt/log/nfcs/nfcs1.log, true
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: setFile ended
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Parsed "dest1"
options.
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Handling
log4j.additivity.nfcs=[null]
[8/14/03 11:11:31:521 CDT]  a75ba9f SystemOut     O log4j: Finished
configuring.
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: rolling over
count=51507
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: maxBackupIndex=3
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: Renaming file
c:\apps\ipt\log\nfcs\nfcs1.log to c:\apps\ipt\log\nfcs\nfcs1.log.1
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: setFile called:
c:/apps/ipt/log/nfcs/nfcs1.log, false 
[8/14/03 11:13:04:413 CDT] 4e65babb SystemOut     O log4j: setFile ended


This e-mail and any files transmitted with it are the property of SBC, are
confidential, and are intended solely for the use of the individual or
entity to whom this e-mail is addressed.  If you are not one of the named
recipient(s) or otherwise have reason to believe that you have received this
message in error, please notify the sender at (312) 220-8886 and delete this
message immediately from your computer.  Any other use, retention,
dissemination, forwarding, printing, or copying of this e-mail is strictly
prohibited."

312-727-2012
Thanks
Manoj


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message