Java – Log4j output on console instead of configured file

configuration, console, file, java, log4j

I configured Log4j to log into a file but it is instead logging to stdout.
it creates the log file but it does not write to it, instead to stdout.

Here is my config file:

log4j.rootCategory=INFO, file, maillog4j.appender.file=org.apache.log4j.RollingFileAppenderlog4j.appender.file.File=/path-to/jobs-batch.loglog4j.appender.file.MaxFileSize=10MBlog4j.appender.file.MaxBackupIndex=2log4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=[jobs-batch] %p [%t] %c{1}.%M(%L) | %m%nlog4j.logger.org.springframework.jdbc=WARN# Configuration for receiving e-mails when ERROR messages occur.log4j.appender.m[email protected][email protected]MTPHost=mail.xxx.delog4j.appender.mail.Threshold=ERRORlog4j.appender.mail.Subject=Jobs Batch Errorlog4j.appender.mail.layout=org.apache.log4j.PatternLayoutlog4j.appender.mail.layout.ConversionPattern=%d  %-5p %c %x - %m%n

any ideas?

Thanks

Best Solution

Adjust to suite your needs:

log4j.rootCategory=DEBUG, C     log4j.appender.C=org.apache.log4j.ConsoleAppenderlog4j.appender.C.layout=org.apache.log4j.PatternLayoutlog4j.appender.C.layout.ConversionPattern=%d{MMddyyyy HH:mm} %-5p %c{1}:%L - %m%nlog4j.appender.C.Target=System.out