I am having trouble printing stacktrace in a log file. Log4j.properties:
log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=/var/log/app/application.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n log4j.rootLogger=warn, file log4j.logger.com.app=info, file log4j.additivity.com.app=false
when I register an exception like this in my UserGuard.java class:
} catch (Exception e) { log.error("Uncatched error", e); response.setEntity(new StringRepresentation(" ")); response.setStatus(Status.SERVER_ERROR_INTERNAL); }
This leads to my application.log:
2011-12-28 07:30:03 UserGuard [ERROR] Uncatched error java.lang.NullPointerException
No stack trace. This is really annoying. Thanks!
I tried with the same pom.xml and the same log4j.properties on another machine and it works fine. Should I think that the problem is in my version of Java?
source share