This is a personal project and I just want this to work.
I have a Java 8 application that is using Log4j 2 and all I want to do is get it to log to one of the general Tomcat 9 logs like catalina.out or localhost or the tomcat stdout log. Nothing I do seems to work.
Log4J is included in the war file, I only need it to work for this one application under Tomcat 9. I do not want to move to another logging library. This is my log4j.properties
file.
log4j.rootCategory=debug,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.immediateFlush=true
log4j.appender.console.encoding=UTF-8
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%d [%t] %-5p %c - %m%n
This is an example of how I'm using this in my code:
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public final class DataController {
private static Logger LOG = LogManager.getLogger(DataController.class);
public void exampleMethod() {
LOG.info("Log something");
}
}
Nothing shows up in any log. Tomcat 9 is a stock install and has a stock logging.properties
file. This is NOT a Spring application. It is pure Java Servlets and POJO. For further context, I did originally use a file appender and logged to a custom file. That didn't work either. By the way, although I know some of the terminology, I am a complete noob at Java.
I was using a log4j 1.2 properties file. This sample properties file worked.