0

We have a Java application running on a CentOS server running JRE 6 which does some logging to System.out and to three log files (info, warning and errors). We have used log4j for months now and never had any issues. Today the application crashed for some unknown reason which we will look into, but upon starting the application again, log4j would not log to the files anymore. Instead, it is logging everything to System.out (thus we have every log message duplicated in the console window). At first we thought the log files were locked for some reason and deleted them, but the files were never recreated.

Note: restarting the machine is not currently an option.

This is part of our log4j.properties file (omitted two similar parts which write to the two other log files)

# Define the root logger with appender file
log = logs
log4j.rootLogger = DEBUG, GENERAL, SUSPICIOUS, DANGEROUS

# Define the GENERAL appender
log4j.appender.GENERAL=org.apache.log4j.DailyRollingFileAppender
log4j.appender.GENERAL.Threshold=INFO
log4j.appender.GENERAL.filter.a=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.GENERAL.filter.a.LevelToMatch=INFO
log4j.appender.GENERAL.filter.a.AcceptOnMatch=true
log4j.appender.GENERAL.filter.b=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.GENERAL.filter.b.LevelToMatch=WARN
log4j.appender.GENERAL.filter.b.AcceptOnMatch=false
log4j.appender.GENERAL.filter.c=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.GENERAL.filter.c.LevelToMatch=ERROR
log4j.appender.GENERAL.filter.c.AcceptOnMatch=false
log4j.appender.GENERAL.File=${log}/Info.log
Jurgen Camilleri
  • 3,559
  • 20
  • 45
  • Out of disk space? Application user can no longer write to those log folders? – Duncan Jones Feb 20 '15 at 15:02
  • Did you see that http://stackoverflow.com/questions/14242035/log4j-suddenly-stops-logging – Semih Eker Feb 20 '15 at 15:02
  • Plenty of disk space left and not a permissions issue either. I saw that question but no answer helped. – Jurgen Camilleri Feb 20 '15 at 15:03
  • I have the suspicion that the reason for the crash might also be the reason for log4j to behave strangely ... Did you find out why it crashed? – Fildor Feb 20 '15 at 15:13
  • I didn't have time, it was a `NoClassDefFoundError` in a part of the code which is rarely executed. Something to do with a `JSON` library. I'll look into it further when I have time but I can't see the connection. Log4j did log this error successfully by the way, in fact it continued logging for a good 5 minutes until the application realised something went wrong and started shutting down. It didn't log until the very end though. I could post the stack trace but I'm afraid its irrelevant. – Jurgen Camilleri Feb 20 '15 at 15:19
  • In that case, you are right. Then my suspicion was wrong. Can you freely restart the application after working hours or does it have to run continuously? – Fildor Feb 20 '15 at 16:29
  • The application can be stopped for short periods of time, in fact I've tried it multiple times to no avail - it's the server machine that cannot be restarted for other reasons. – Jurgen Camilleri Feb 20 '15 at 16:31
  • 1
    possible to change the log file name and restart? Change the properties to try logging to Info_1.log. Could still be a file locking issue – kjp Feb 20 '15 at 17:09

0 Answers0