I am using log4j-1.2.16 and facing the following problem: 20-Nov-2014 logs are being written in xyz.log.2014-11-19 . xyz.log.2014-11-19 is already rotated/rolled log. I havent done any changes in log4j.properties since 1 year approximately. Please tell me what is causing it and is it an existing bug or not . If it is an existing bug then in which version it was fixed. Please suggest how to fix this. Web Server = Apache 2.4.4 Tomacat 7 Linux 2.6.18-348.el5 x86_64 java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) Below is my log4j.properties: log4j.rootLogger=INFO,logfile log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.DatePattern='.'yyyy-MM-dd log4j.appender.logfile.File=/home/user/product//log/xyz.log log4j.appender.logfile.encoding=UTF-8 log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d{dd MMM yyyy HH\:mm\:ss} %-5p [%t] %-15C{1} - %m%n log4j.logger.org.hibernate=FATAL log4j.logger.net.htmlparser.jericho=FATAL log4j.logger.com.mchange=FATAL log4j.logger.com.sshtools=FATAL log4j.logger.com.mysql.jdbc=FATAL log4j.rootCategory=debug, dest2 log4j.appender.dest2=org.apache.log4j.RollingFileAppender log4j.appender.dest2.Threshold=DEBUG log4j.appender.dest2.File=log/purge2.log log4j.appender.dest2.Append=true log4j.appender.dest2.MaxFileSize=10MB log4j.appender.dest2.MaxBackupIndex=2 log4j.appender.dest2.layout=org.apache.log4j.PatternLayout log4j.appender.dest2.layout.ConversionPattern=[%d{ISO8601}][%t](%F\:%L) - %m%n
Hi Sid, All of our energy is focus on version 2 these days. I would try using 1.2 17 first and see if that helps. If not, consider 2.1, that's where we are fixing bugs these days.
Hi Gary the scenario is something like this : 1) There are two versions of same application accessing same tomcat Ex- MyApp 7.0.0 and MyApp 8.0.0 are configured to write in the same log ui_myapp.log . The real problem is MyApp 8.0.0 is writing in ui_myapp.log and MyApp 7.0.0 is writing in ui.myapp.log.2014-11-24 (suppose current date is 2014-11-25 ) . 2) Another problem is it overwriting or replacing all the content in ui.myapp.log.2014-11-24 . I replaced the old jar with log4j-1.2.17.jar with but it doesnt help. Is this the problem with DailyRollingFileAppender ? If yes then please inform the version in which this is fixed. Or please suggest any alternative.
The Log4j 1.2.16 documentation (I checked the 1.2.16 sources) recommends avoiding using this appender, as documented in https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html: “DailyRollingFileAppender has been observed to exhibit synchronization issues and data loss. The log4j extras companion includes alternatives which should be considered for new deployments and which are discussed in the documentation for org.apache.log4j.rolling.RollingFileAppender.”
Sure !! Thanks for the reply ...For now we have configured two separate log files for the two Applications .