I have a log4j.properties file:
log4j.logger.com.mypackage=debug, R, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=myapplication.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
logging into stdout works fine, if I change "debug" in the first line to "error" I get only the error msgs in stdout.
the myapplication.log gets created but it's empty. If I remove the "R" from the first line, the file will not be created.
ll shows the file as
-rw-r--r-- 1 <myname> staff 0B Oct 28 16:26 myapplication.log
I did a chmod 777 myapplication.log but that didn't help.
I'm on OS X 10.11.1 using STS 3.6.4
I searched google and stackoverflow but couldn't find a solution so far.
edit: I changed the line
log4j.logger.com.mypackage=debug, R, stdout
to
log4j.rootLogger=debug, R, stdout
Now the messages are written into the file, but only those that are not from mypackage.
I changed the file location to
log4j.appender.R.File=${catalina.home}/logs/myapplication.log
now I get my logging messages written into the file.
I have no idea why this work but write to myapplication.log (without a path) writes only log messages from other libraries in there.