It seems like Log4j is not logging any message containing "Task" using a ConsoleAppender.
public class Main
public static void main(String[] args)
{
Log log = LogFactory.getLog("Main");
log.info("'task' is logged, but");
log.info("'Task' is not logged ?!");
// wait for logging to finish
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
log4j.properties:
log4j.rootLogger = TRACE, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.conversionPattern=%d{HH:mm:ss.SSS} %-5p %c.%M - %m%n
I use commons-logging 1.2, log4j 1.2.17, openjdk version "13.0.2" 2020-01-14
Is this a bug? A FileAppender works normally. I can also System.out.println("Task") and see it on the console, so it is not my IDE filtering anything.
I would be happy if someone can try this and verify it, because I am super confused.
It turns out that my IntelliJ IDEA plugin Grep Console was filtering lines with .*Task.*
due to import of the company configuration.
In IntelliJ, go to Settings > Other Settings > Grep Console > Input filtering. Check if there is any unexpected.