Hi all,
I have the problem that log4j does not create a backup file, when another java process (for example) also reads from this file. Here are my log4j properties:
------------------------------
log4j.category.allErrors=DEBUG, fileout_allErrors
log4j.appender.fileout_allErrors=org.apache.log4j.RollingFileAppender
log4j.appender.fileout_allErrors.File=C:/ican50/bhb_bhs/logs/allErrors.log
log4j.appender.fileout_allErrors.MaxFileSize=10MB
log4j.appender.fileout_allErrors.MaxBackupIndex=5
log4j.appender.fileout_allErrors.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout_allErrors.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss.SSS} - %5p [%t] - %m => %C{1}.%M%n
------------------------------
So, after 10 MB of data in the file allErrors.log, a backup should be created (allErrors.log.1) and all upcoming data should be logged into the new allErrors.log file.
This all works perfect, as long as no other process "monitors" the allErrors.log file.
My problem is, that I have a small java program that simulates the good all "tail" command from UNIX, so that I always see the latest information of the log file in my application. This process holds some kind of lock on the watched log-file (this is not explicetly done by me, but must be some implicit lock, I guess) and so log4j does not create the backup (allErrors.log.1) at all, but removes all data from the allErrors.log file and starts from 0 again. As a result the 10 MB previously logged (that have been in the allErrors.log) are lost!
Any ideas what I can do to solve this problem?!
Thanks for any help and regards
Bernhard Boehm
I have the problem that log4j does not create a backup file, when another java process (for example) also reads from this file. Here are my log4j properties:
------------------------------
log4j.category.allErrors=DEBUG, fileout_allErrors
log4j.appender.fileout_allErrors=org.apache.log4j.RollingFileAppender
log4j.appender.fileout_allErrors.File=C:/ican50/bhb_bhs/logs/allErrors.log
log4j.appender.fileout_allErrors.MaxFileSize=10MB
log4j.appender.fileout_allErrors.MaxBackupIndex=5
log4j.appender.fileout_allErrors.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout_allErrors.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss.SSS} - %5p [%t] - %m => %C{1}.%M%n
------------------------------
So, after 10 MB of data in the file allErrors.log, a backup should be created (allErrors.log.1) and all upcoming data should be logged into the new allErrors.log file.
This all works perfect, as long as no other process "monitors" the allErrors.log file.
My problem is, that I have a small java program that simulates the good all "tail" command from UNIX, so that I always see the latest information of the log file in my application. This process holds some kind of lock on the watched log-file (this is not explicetly done by me, but must be some implicit lock, I guess) and so log4j does not create the backup (allErrors.log.1) at all, but removes all data from the allErrors.log file and starts from 0 again. As a result the 10 MB previously logged (that have been in the allErrors.log) are lost!
Any ideas what I can do to solve this problem?!
Thanks for any help and regards
Bernhard Boehm