How to enable check-in at the pier?

I am trying to debug my case when the JetWeb application does not work under Jetty. It behaves as if no classes to process the request exist and return a 404 error.

The question is not ActiveWeb. It's about Jetty. How do I know if with some web application Jetty is fond of an annotated class and will execute it on an HTTP request?

I currently downloaded Jetty and it works. Unfortunately, he does not register. Nothing is displayed in stdout or stderr , and no files are displayed in the logs subdirectory at the moment the 404 error is returned.

How to enable logging at the pier?

The documentation is 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 not clear and contradictory.

For example, the first page says that Jetty does not use the Java loggin framework, but also requires it to choose one. The second page provides an example configuration, but does not say where this code should be indicated.

+6
source share
1 answer

The documentation is correct because the term "Java Logging Framework" is often associated with modern logging frameworks such as java.util.logging, slf4j, logback, log4j, commons-logging, logkit, etc.

That's right, Jetty doesn't use them.

Launching moorings precedes all of these efforts in a standardized logging framework. (Jetty, and its registration level was created in 1995)

This is what Jetty logs (and is documented on the documentation site) regarding setup and configuration.

Default behavior:

  • If slf4j is present in your classpath, it will generate logging events in slf4j for processing using Slf4jLog .
  • Return to StdErrLog , emitting in System.err.

To configure:

This can be done in three different ways.

  • Using a system property to set logging impl
 # 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 
  1. Using jetty-logging.properties self-discovery / configuration found from classpath.

An example from the pier 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 
  1. Using code to install Log.setLog(Logger)

This is especially useful for those using

 import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.StdErrLog; Log.setLog(new StdErrLog()); 

Tips and notes:

The startup output of your Jetty server will give you hints about the implementation of the protocol that it uses.

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 

Note that it does not have a namespace declaration or a greatly reduced namespace. This tells me that StdErrLog is being used.

If using slf4j:

 10:50:18.871 [main] INFO org.eclipse.jetty.util.log - Logging initialized @352ms 10:50:19.102 [main] INFO oejdpScanningAppProvider - Deployment monitor [file:/Users/joakim/Code/Jetty/distros/jetty-distribution-9.2.1.v20140609/demo-base/webapps/] at interval 1 

This is the default appender console for slf4j - slf4j logback . The general structure here is very different from what StdErrLog , so I can now say that the pier emits an implementation of Slf4jLog .

+20
source

Source: https://habr.com/ru/post/975124/


All Articles