Log4j stopped writing to the file,

I use log4j in my java application, but after some time, without throwing any exceptions, it stopped recording

my log4j configuration is as below.

log4j.rootLogger=INFO,FILE log4j.appender.FILE=com.test.TestFIleAppender log4j.appender.FILE.MaxFileSize=20MB log4j.appender.FILE.MaxBackUpIndex=200 

My application file contains the code to perform the zip operation and specify the format of the log file and all.

It was a log for some time, but it suddenly stopped logging, an exception was also not thrown

can any body tell me what could be the problem?

does any authority know any log4j related problems?

+7
java log4j
source share
5 answers

It happened to me. It works one day, and then does not work further. I came back and realized that I had changed the POM dependencies and made some search queries.

When I fixed this problem, my log returned. I would make sure you have the following artifacts in sync:

  <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> 

http://www.slf4j.org/manual.html

+4
source share

It is hard to answer why your journal is stopping.

First check the space on your hard drive to see if it is full.

Then write a test file in which the thread polls a registration message of type INFO every second. Then you can check if this is a space or memory problem.

Please note: when the program waits somewhere and not a single thread or action is working, you will not see any registration messages. Please check, by debugging, whether a line of code is executed in a loop (or as you expected to see messages) in which a registration message should be displayed.

This is an example of my log4j properties file. Maybe this is useful:

 log4j.rootLogger=INFO, stdout, logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) [%c] - %m%n log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.File=C:/log/client.log log4j.appender.logfile.MaxFileSize=5MB log4j.appender.logfile.MaxBackupIndex=0 log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n 
+1
source share

Have you considered the likelihood that log4j is still being written to the file, but this file has been detached from the parent directory by your user application?

0
source share

This happened to me after adding a sardine library to my dependencies. Then from one of the answers here, I added the slf4j-log4j12 library to the dependencies, and it started working again.

0
source share

This is probably a very rare situation, but I once ran into a similar problem caused by using Cloner . After cloning an object with log4j enabled, logging simply stopped working. The solution was to exclude the log4j classes from cloning with:

cloner.dontClone(org.apache.log4j.Logger.class, org.apache.log4j.LogManager.class,)

0
source share

All Articles