In a Maven project I've put the log4j.properties file in src\main\resources catalog which seems to be the usual place to put it in. However it does not appear to read it or there is a mistake I can't see as my logger doesn't print DEBUG level messages (it does print INFO level messages though) and doesn't create the logs.log file either. Here's the log4j.properties file I'm using:
# Root logger option
log4j.rootLogger=DEBUG, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=D:/.../src/main/resources/META-INF/logs.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
I've also tried to pass the path to the log4j.properties file in my run configuration but it didn't work either:
-Dlog4j.configuration=file:D:/.../src/main/resources/log4j.properties
This project is launched through a different bound project so I used the entire file path which might be incorrect as none of the examples I've seen had full paths provided.
The server we're using to run the app is Wildfly 8.1.0 which has it's own log4j logger so maybe that's interfering somehow?
Here's the part of my interceptor which should create logs:
final static Logger logger = Logger.getLogger(RestInterceptor.class);
...
if(e instanceof ApplicationException) {
logger.debug(e.getMessage(), e);
//TODO remove these when done testing
logger.debug("debug is working");
logger.info("info is working");
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
However only "info is working" is being printed.