The log4j configuration does not work for a specific class

advertisements

I have a class which I want to redirect its log output to a file. But no matter what I do, it always outputs to the console. Here is my log4j.properties file.

log4j.rootLogger=INFO, 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} %C %l %-5p %c{1}:%L - %t - %m%n

log4j.logger.io.opentracing.impl.LoggingEventBuilder=INFO, ul
log4j.additivity.io.opentracing.impl.LoggingEventBuilder=false
log4j.appender.ul=org.apache.log4j.RollingFileAppender
log4j.appender.ul.maxFileSize=50MB
log4j.appender.ul.file=${catalina.home}/logs/mylogs.log
log4j.appender.ul.layout=org.apache.log4j.PatternLayout
log4j.appender.ul.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %t - %m%n

Here io.opentracing.impl.LoggingEventBuilder is the class whose output I want to redirect. The interesting thing is that I tried to redirect output from other classes to a file using the same code pattern and it worked. Only for this class it does not work.

I am using slf4j-log4j12. What am I missing?


Thanks a lot for the hint. That pointed me to the correct solution. Apparently the authors of that library defined their logger as something like FooLogging. So I changed these two lines:

log4j.logger.io.opentracing.impl.LoggingEventBuilder=INFO, ul
log4j.additivity.io.opentracing.impl.LoggingEventBuilder=fal‌​se

to

log4j.logger.FooLogging=INFO, ul
log4j.additivity.FooLogging=false

and that solved the problem.