I am trying to debug my case, where simple ActiveWeb application is not running under Jetty. It behaves as if no any classes for request processing exist and return error 404.
The question is not about ActiveWeb. It is about Jetty. How to find out, that having some web application, Jetty has fond annotated class and will execute it on HTTP request?
Currently I have downloaded Jetty and it works. Unfortunately, it does no logging. Nothing is displayed in stdout
or stderr
and no files appear in logs
subdirectory at the moment, when 404 error returns.
How to enable logging in jetty?
Documentation here http://www.eclipse.org/jetty/documentation/current/configuring-logging.html and here http://www.eclipse.org/jetty/documentation/current/configuring-jetty-request-logs.html is not clear and controversal.
For example, first page says Jetty does not use any Java loggin framework, but also requires one to select one. The second page provides some example of configuration, but does not say, where this code should be put.
jetty. LEVEL", "OFF"); This worked for me, but just make sure to call it before starting the server.
Jetty is now configured to log using the Log4j framework. A standard Log4j configuration file is located in ${jetty. base}/resources/log4j. xml .
Starting with Jetty 10.0.0, there is no longer a "Jetty Logging" facade.
The Jetty project has moved to using SLF4J 2.0 only.
The documentation is correct, as the term "Java Logging Framework" is often associated with modern logging frameworks like java.util.logging, slf4j, logback, log4j, commons-logging, logkit, etc.
This is correct, Jetty does not use any of those.
Jetty logging predates ALL of those efforts at standardized logging frameworks. (Jetty, and its logging layer was created in 1995)
This is what Jetty logging does (and is documented at the documentation site) with regards to setup and configuration.
Default behavior:
To configure:
This can be accomplished in 3 different ways
# 3 different options
-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog
-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog
jetty-logging.properties
self discover/configuration found from classpath.Example from jetty project itself:
# Configure for System.err output
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
# Configure StdErrLog to log all jetty namespace at default of WARN or above
org.eclipse.jetty.LEVEL=WARN
# Configure StdErrLog to log websocket specific namespace at DEBUG or above
org.eclipse.jetty.websocket.LEVEL=DEBUG
Log.setLog(Logger)
This is particularly useful for those using embedded-jetty
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.StdErrLog;
Log.setLog(new StdErrLog());
Advice and Notes:
The output of your Jetty server startup will give you hints about the logging implementation it is using.
Normal / Default behavior:
2014-09-11 10:48:38.726:INFO::main: Logging initialized @378ms
2014-09-11 10:48:39.067:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/Users/joakim/Code/Jetty/distros/jetty-distribution-9.2.1.v20140609/demo-base/webapps/] at interval 1
Notice that this has either no namespace declaration, or heavily abbreviated namespace in its output. This tells me that the StdErrLog
is in use.
If slf4j is in use:
10:50:18.871 [main] INFO org.eclipse.jetty.util.log - Logging initialized @352ms
10:50:19.102 [main] INFO o.e.j.d.p.ScanningAppProvider - Deployment monitor [file:/Users/joakim/Code/Jetty/distros/jetty-distribution-9.2.1.v20140609/demo-base/webapps/] at interval 1
This is a default Console appender output for slf4j
-> logback
. The overall structure here is very different that what the StdErrLog
produces, so I can now tell that jetty is emitting via the Slf4jLog
implementation.
In my case, I've solved it by following the recommendations in the documentation page (Default Logging with Jetty’s StdErrLog) and adding the following line in the start.ini file: --module=console-capture
I know this is only one way of solving your problem, but it worked out pretty well for me. After restarting the service, I could already see a log file in the logs subdirectory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With