0

I have a java webapp that uses log4j to log messages. This webapp is a wrapper around a jar file that I have written. When I run my webapp through the built-in Jetty from Eclipse, my JAR's logs (LOG.info(...) messages) are printed out just fine. Now, I have downloaded a standalone instance of Jetty and have run my web app from there. With the default log4j settings packaged with Jetty, I am not able to see ANY logs from my JAR. I only see the Jetty logs and the webapp's logs.

I have found the log4j.properties file under the resources folder, but am not sure what I need to change in it to get my app's logs to show. I had thought that Jetty worked out of the box with basic log4j logging.

1 Answer 1

1

Jetty doesn't use log4j.

You'll need to configure your ${jetty.base} (Important Note: do not edit/modify/delete any content in ${jetty.home}) to use slf4j first, log4j second.

$ cd /path/to/myjettybase $ java -jar /path/to/jetty-dist/start.jar --add-to-start=resources,ext 

Next, go download slf4j-api.jar, slf4j-log4j##.jar (where ## is the support version of log4j you want to use), and log4j.jar and put them in the new ${jetty.base}/lib/ext directory.

Finally, put your log4j.xml in your ${jetty.base}/resources/ directory.

That's it, you've setup Jetty Distribution for log4j use.

Sign up to request clarification or add additional context in comments.

5 Comments

Actually, I forgot I am using logback instead of log4j, but anyways... I added the logback jars and I am getting log messages saying multiple slf4j bindings have been found.
Forgot to elaborate... I am seeing some debug messages from my app, but the explicit LOG.info(...) messages are still not getting printed
You can't have app generated logging pass through the WebApp isolation layers. You either have Server logging, or App logging, each configured separately, with different Appenders (and file locations!)
I updated my OP. I just realized that the issue is not with my webapp, but a jar that is packaged with the webapp. That jar's logging is not printed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.