i_am_diablo2000
asked on
Log4j problem. not able to create backup for multiple jvm
Not sure this is the right folder, but please help me.
This is my log4j configuration file.
log4j.logger.test=debug, app1
log4j.appender.consolestdo ut=org.apa che.log4j. ConsoleApp ender
log4j.appender.consolestdo ut.layout= org.apache .log4j.Pat ternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.consolestdo ut.layout. Conversion Pattern=%d {dd/MM/yy, HH:mm:ss} %5p [%t] - %m%n
# Configure the file appender : app1
log4j.appender.app1=org.ap ache.log4j .RollingFi leAppender
log4j.appender.app1.File=d :/test/log s/test.log
log4j.appender.app1.MaxFil eSize=1MB
# Keep 4 backup file
log4j.appender.app1.MaxBac kupIndex=4
log4j.appender.app1.layout =org.apach e.log4j.Pa tternLayou t
log4j.appender.app1.layout .Conversio nPattern=% d{dd/MM/yy ,HH:mm:ss} %5p [%t] - %m%n
The observation is :
If I only run one Java application that creates this log file, then everything is fine. It is able to create backup file like test.log1 and test.log2 after it reaches file size 1MB.
The problem is :
If I have multiple Java applications (multiple JVM) that use this log file (this file appender) then I found it is not able to create backup file. It always stays at test.log after it reaches 1MB file size. The previous content will be just cleared and then create a new same file.
It might make sense but is there a way to over come this? This is to say I want to make it no difference from 1 JVM or multiple JVM for the log file behavior.
Thank you very much.
This is my log4j configuration file.
log4j.logger.test=debug, app1
log4j.appender.consolestdo
log4j.appender.consolestdo
# Pattern to output the caller's file name and line number.
log4j.appender.consolestdo
# Configure the file appender : app1
log4j.appender.app1=org.ap
log4j.appender.app1.File=d
log4j.appender.app1.MaxFil
# Keep 4 backup file
log4j.appender.app1.MaxBac
log4j.appender.app1.layout
log4j.appender.app1.layout
The observation is :
If I only run one Java application that creates this log file, then everything is fine. It is able to create backup file like test.log1 and test.log2 after it reaches file size 1MB.
The problem is :
If I have multiple Java applications (multiple JVM) that use this log file (this file appender) then I found it is not able to create backup file. It always stays at test.log after it reaches 1MB file size. The previous content will be just cleared and then create a new same file.
It might make sense but is there a way to over come this? This is to say I want to make it no difference from 1 JVM or multiple JVM for the log file behavior.
Thank you very much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.