Thus Nahoďme dependency: <dependency> <groupId> ch.qos.logback </ groupId> <artifactId> logback-classic </ artifactId> <version> 1.0.13 </ version> <scope> runtime </ scope> </ dependency >
Artifact logback-classic book shall bring transitive dependency on logback-core and ... dependency on slf4j-api. The specialty is the only scope set at runtime: Although our application depends on logback, accounting but it needs to successfully compile. It needs only at run time (even only as an optional component, but in Mave set reasonably know).
If you tighten the project Spring, we get a completely free commons-logging (aka the second biggest mistake in the history of Java logging). However, this means that we have two sets of different logging API and beautiful chaos: our application will be logged to slf4j over logback. and Spring will be logged via commons-logging, which, accounting nenájduc any implementation, naposiela accounting all through the standard java.util.logging (first biggest mistake in the history of Java).
Author slf4j (and also the producer and also the author of log4j logback u) Sipil that such projects will occur in the stew and introduced a set of adapter modules, which can eg. take commons-logging and connect it to slf4j, which will join the logback. This example can convince Spring to use the same mechanisms accounting as logging your application.
Logging event thus climb over the joyful accounting oven frameworks: | -------- | | ----------------- | | ------------ ---- | | ----------- | | --------- accounting | | Spring accounting | ---> | commons-logging | ---> | jcl-over slf4j | ---> | slf4j-api | ---> | logback | | -------- | | ----------------- | | - -------------- | | ----------- | | --------- |
This is one step, we need a blow dependency on commons-logging in the Spring. The Mave be resolved accounting through dependency exclusions, thus banning dependencies: <dependency> <groupId> accounting org.springframework </ groupId> <artifactId> spring-webmvc </ artifactId> <version> 3.2.3.RELEASE </ version> <exclusions accounting > <exclusion> <artifactId> commons-logging </ artifactId> <groupId> commons-logging </ groupId> </ exclusion> </ exclusions> </ dependency> Standard accounting crazy settings
we saw a flood of DEBUG buzz (and endless start Jetty container). Have only one visit to the controller via the browser would cause 9 reports from inside Spring MVC: 17: 15: 59.578 [qtp209879718-31] DEBUG osweb.servlet.DispatcherServlet accounting - DispatcherServlet with name 'dispatcher' processing GET request for [/ log] 17:15 : 59.586 [qtp209879718-31] DEBUG oswsmmaRequestMappingHandlerMapping - Looking up handler method for path / log 17: 15: 59.594 [qtp209879718-31] oswsmmaRequestMappingHandlerMapping DEBUG - Returning handler method [public java.lang.String sk.upjs.ics.novotnyr.mjss .LoggingController.onLog ()] 17: 15: 59.595 [qtp209879718-31] osbfsDefaultListableBeanFactory DEBUG - Returning cached instance of singleton bean 'loggingController' 17: 15: 59.598 [qtp209879718-31] DEBUG osweb.servlet.DispatcherServlet - Last-Modified value for [/ log] is: -1 17: 15: 59.624 [qtp209879718-31] accounting INFO suinmjss.LoggingController - Accessing onLog () 17: 15: 59.664 [qtp209879718-31] DEBUG oswsmmaRequestResponseBodyMethodProcessor - Written [OK] as "text / html "using [org.springframework.http.converter.StringHttpMessageConverter@9efb34] 17: 15: 59.665 [qtp209879718-31] DEBUG osweb.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request accounting handling 17: 15: 59,667 [qtp209879718-31] DEBUG osweb.servlet.DispatcherServlet - Successfully completed request
If we deliver within src / main / resources konfigurák logback.xml, we can limit the level of logging Buzz: <configuration> <appender name = "STDOUT" class = "ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>% d {HH: mm: SS.sss} [% thread]% -5level% logger {36} -% msg% n </ pattern> accounting </ encoder> </ appender> <root level = "INFO"> <appender- ref ref = "STDOUT" /> </ root> <logger name = "sk.upjs.ics.novotnyr.mjss" level = "DEBUG" /> </ configuration>
All loggers logging information will only INFO messages and important, accounting but our special controller will be logged at DEBUG and higher. This dramatically truncating the log messages from Jetty How does the packaged WAR?
The resulting WAR will be in the WEB-INF / lib include: jcl-over-slf4j-1.7.5.jar logback-classic-1.0.13.jar logback-core-1.0.13.jar slf4j-api-1.7.5.jar spring -aop-3.2.3.RELEASE.jar spring-beans-3.2.3.RELEASE.jar spring-context-3.2.3.RELEASE.jar spring-core-3.2.3.RELEASE.jar spring-expression-3.2.3 .RELEASE.jar spring-web-3.2.3.RELEASE.jar spring-webmvc-3.2.3.RELEASE.jar aopalliance-1.0.jar
Logging accounting in libraries conglomerate accounting Spring / slf4j / logback / Maven / Jetty is ultimately simple: YO dependence on logback at random dependency on JCL-over-slf4j dependency to deny what
No comments:
Post a Comment