Revision c374a931
Added by Andreas Kohlbecker over 2 years ago
src/main/java/eu/etaxonomy/cdm/server/logging/LoggingConfigurator.java | ||
---|---|---|
17 | 17 |
/** |
18 | 18 |
* The technique used in this class is based on the example |
19 | 19 |
* for a jetty server which uses a deployment manager, explained |
20 |
* in https://www.eclipse.org/jetty/documentation/9.4.29.v20200521/example-logging-logback-centralized.html.
|
|
20 |
* in http://www.eclipse.org/jetty/documentation/jetty-9/index.html#example-logging-logback-centralized
|
|
21 | 21 |
* In our situation of an embedded jetty which manages the cdm-webapp instance directly the |
22 | 22 |
* configuration need to be a bit different. |
23 | 23 |
* |
24 |
* The config files of the official example can be downloaded from |
|
25 |
* https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-webapp-logging/9.4.20.v20190813/jetty-webapp-logging-9.4.20.v20190813-config.jar |
|
26 |
* extract the jar to examine the contained config files. |
|
24 |
* The config files of the official example can found on github: |
|
25 |
* https://github.com/jetty-project/jetty-webapp-logging/ |
|
27 | 26 |
* |
28 | 27 |
* @author a.kohlbecker |
29 | 28 |
* @since Jun 10, 2020 |
... | ... | |
33 | 32 |
public void configureServer() { |
34 | 33 |
// Configure logging (1) |
35 | 34 |
|
36 |
// > jetty-webapp-logging-9.4.20.v20190813-config/etc/jetty-jul-to-slf4j.xml |
|
35 |
// v20190813 > https://github.com/jetty-project/jetty-webapp-logging/blob/jetty-webapp-logging-9.4.20.v20190813/jetty-webapp-logging/src/main/config/etc/jetty-jul-to-slf4j.xml |
|
36 |
// Apr 2, 2020 > https://github.com/jetty-project/jetty-webapp-logging/blob/master/jetty-webapp-logging/src/main/config/etc/jetty-jul-to-slf4j.xml |
|
37 | 37 |
SLF4JBridgeHandler.removeHandlersForRootLogger(); |
38 | 38 |
SLF4JBridgeHandler.install(); |
39 | 39 |
// > |
... | ... | |
44 | 44 |
|
45 | 45 |
public Handler configureWebApp(WebAppContext cdmWebappContext, CdmInstance instance) { |
46 | 46 |
|
47 |
// > jetty-webapp-logging-9.4.20.v20190813-config/etc/jetty-webapp-logging.xml |
|
47 |
// v20190813 > https://github.com/jetty-project/jetty-webapp-logging/blob/jetty-webapp-logging-9.4.20.v20190813/jetty-webapp-logging/src/main/config/etc/jetty-webapp-logging.xml |
|
48 |
// Apr 2, 2020 > https://github.com/jetty-project/jetty-webapp-logging/blob/master/jetty-webapp-logging/src/main/java/org/eclipse/jetty/webapp/logging/CentralizedWebAppLoggingBinding.java |
|
48 | 49 |
// ---> adds the org.eclipse.jetty.webapp.logging.CentralizedWebAppLoggingBinding |
49 | 50 |
// (from jetty-webapp-logging-9.4.20.v20190813.jar) to the DeploymentManager, |
50 | 51 |
// in the cdm-server we are not using the DeploymentManager so |
51 |
// this needs to be done per web app explicitely:
|
|
52 |
// this needs to be done per web app explicitly: |
|
52 | 53 |
cdmWebappContext.getSystemClasspathPattern().add("org.apache.log4j."); |
53 | 54 |
cdmWebappContext.getSystemClasspathPattern().add("org.slf4j."); |
54 | 55 |
cdmWebappContext.getSystemClasspathPattern().add("org.apache.commons.logging."); |
55 | 56 |
|
56 |
// > jetty-webapp-logging-9.4.20.v20190813-config/etc/jetty-mdc-handler.xml |
|
57 |
// UPDATE: |
|
58 |
// in the latest version of the jetty-webapp-logging (Apr 2, 2020) the classnames are also removed from the ServerClasspathPatterns: |
|
59 |
cdmWebappContext.getServerClasspathPattern().add("-org.apache.log4j."); |
|
60 |
cdmWebappContext.getServerClasspathPattern().add("-org.slf4j."); |
|
61 |
cdmWebappContext.getServerClasspathPattern().add("-org.apache.commons.logging."); |
|
62 |
|
|
63 |
|
|
64 |
// v20190813 > https://github.com/jetty-project/jetty-webapp-logging/blob/jetty-webapp-logging-9.4.20.v20190813/jetty-webapp-logging/src/etc/jetty-mdc-handler.xml |
|
65 |
// Apr 2, 2020 > https://github.com/jetty-project/jetty-webapp-logging/blob/master/jetty-webapp-logging/src/main/config/etc/jetty-mdc-handler.xml |
|
57 | 66 |
InstanceLogWrapper mdcHandler = new InstanceLogWrapper(instance.getName()); |
58 | 67 |
mdcHandler.setHandler(cdmWebappContext); // wrap context handler |
59 | 68 |
return mdcHandler; |
Also available in: Unified diff
updating documentation and removing class names from ServerClassPatterns