There is a polling service which fills up my log
2022-01-09T05:24:32,827 DEBUG [ajp-nio-8009-exec-7] o.s.c.l.LogFormatUtils: GET "/VenusD/anonymous/
Somewhat like above. I just need to disable spring logging for a selected controller or request mapping.
What is the right way of doing it? How can I probably exclude it?
If you don't have to change log level of package, comment please.
You can set log level of pacakge.
My log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout
pattern="[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] %-5level %logger{100}.%M - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="DEBUG" additivity="false">
<AppenderRef ref="console" />
</Root>
<!-- <Logger name="org.springframework.web.servlet.DispatcherServlet" level="warn"></Logger> -->
</Loggers>
</Configuration>
My log, When I set log levl debug
[2022-01-09 10:01:34:5876][http-nio-8080-exec-1] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].log - Initializing Spring DispatcherServlet 'dispatcherServlet'
[2022-01-09 10:01:34:5877][http-nio-8080-exec-1] INFO org.springframework.web.servlet.DispatcherServlet.initServletBean - Initializing Servlet 'dispatcherServlet'
[2022-01-09 10:01:34:5877][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initMultipartResolver - Detected StandardServletMultipartResolver
[2022-01-09 10:01:34:5877][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initLocaleResolver - Detected AcceptHeaderLocaleResolver
[2022-01-09 10:01:34:5877][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initThemeResolver - Detected FixedThemeResolver
[2022-01-09 10:01:34:5877][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initRequestToViewNameTranslator - Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator#5889aa66
[2022-01-09 10:01:34:5878][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initFlashMapManager - Detected org.springframework.web.servlet.support.SessionFlashMapManager#25bd45e9
[2022-01-09 10:01:34:5878][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.initServletBean - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
[2022-01-09 10:01:34:5878][http-nio-8080-exec-1] INFO org.springframework.web.servlet.DispatcherServlet.initServletBean - Completed initialization in 1 ms
[2022-01-09 10:01:34:5890][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.traceDebug - GET "/", parameters={}
[2022-01-09 10:01:34:5894][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandler - Mapped to com.example.rest.timeout.controller.ControllerTest#get()
[2022-01-09 10:01:34:5919][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.writeWithMessageConverters - Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8] and supported [application/json, application/*+json, application/json, application/*+json]
[2022-01-09 10:01:34:5919][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.writeWithMessageConverters - Nothing to write: null body
[2022-01-09 10:01:34:5921][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet.logResult - Completed 200 OK
My log, When I remove following comment in log4j2.xml
<!-- <Logger name="org.springframework.web.servlet.DispatcherServlet" level="warn"></Logger> -->
to
<Logger name="org.springframework.web.servlet.DispatcherServlet" level="warn"></Logger>
Debug log level of org.springframework.web.servlet.DispatcherServlet is removed.
[2022-01-09 10:12:34:666106][http-nio-8080-exec-1] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].log - Initializing Spring DispatcherServlet 'dispatcherServlet'
[2022-01-09 10:12:34:666108][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.getHandler - Mapped to com.example.rest.timeout.controller.ControllerTest#get()
[2022-01-09 10:12:34:666109][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.writeWithMessageConverters - Using 'application/json;q=0.8', given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.9, */*;q=0.8] and supported [application/json, application/*+json, application/json, application/*+json]
[2022-01-09 10:12:34:666110][http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.writeWithMessageConverters - Nothing to write: null body
Related
I have a SpringBoot application that I am able to start ( http://localhost:80 ).
In my application.yml :
application:
baseurl: /respViewer/api
In my application I defined a #RestController and an endpoint :
#RestController
#RequestMapping("${application.baseurl}/viewer")
....
#PostMapping(value = "/getRespList", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> getResponsibilities(#RequestBody RequestDetail requestDetail)
When I try to access my application using Insomnia or through the Browser I am getting 404 Error.
http://localhost:8080/respViewer/api/viewer/getRespList
{
"timestamp": "2022-04-25T19:52:32.426+00:00",
"status": 404,
"error": "Not Found",
"message": "",
"path": "/respViewer/api/viewer/getRespList"
}
I also checked console output and found these messages :
POST "/respViewer/api/viewer/getRespList", parameters={}
2022-04-25 15:52:32.253 DEBUG 3744 --- [nio-8080-exec-1] o.s.w.s.h.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2022-04-25 15:52:32.382 DEBUG 3744 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2022-04-25 15:52:32.387 DEBUG 3744 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Completed 404 NOT_FOUND
What am I doing wrong?
Update 1 :
I added packages location where I have a REST Controller to application.yml :
spring:
component:
scan:
packages: com.example.demoRespManager
and now I am not getting 404 Error, however it doesn't look like I am getting into the body of implementation method. I setup a break-point in the first line of the method but never stop there. An output in the Console is :
2022-04-25 21:25:43.749 INFO 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-04-25 21:25:43.750 DEBUG 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Detected StandardServletMultipartResolver
2022-04-25 21:25:43.915 DEBUG 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2022-04-25 21:25:43.915 INFO 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Completed initialization in 166 ms
2022-04-25 21:25:44.134 DEBUG 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : POST "/respViewer/api/viewer/getRespList", parameters={}
2022-04-25 21:25:44.180 DEBUG 27996 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Using #ExceptionHandler com.<my_package_path>.exception.ApplicationExceptionHandler#handleException(Exception, WebRequest)
2022-04-25 21:25:44.254 DEBUG 27996 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor : No match for [application/json], supported: []
2022-04-25 21:25:44.261 DEBUG 27996 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type '' not supported]
2022-04-25 21:25:44.262 DEBUG 27996 --- [nio-8080-exec-1] o.s.w.s.DispatcherServlet : Completed 415 UNSUPPORTED_MEDIA_TYPE
UPDATE 2 :
In the Header section of the INSOMNIA application I added Content-type = application/json, since I defined it in my endpoint, and after that it started to work. I was able to start an application in the DEBUG mode and when I made a POST request in INSOMNIA I stopped at the first line of my method implementation.
I solved this issue :
updated my properties file with the list of the packages that contain the beans, it's an equivalent of #ComponentScan in Application ( spring.component.scan.packages )
Added Content-type = application/json to the Header in the Insomnia.
it is necessary to generate a span-id for all that gets into the console log, but unfortunately the span-id is not generated:
2019-03-13 12:35:27.116 INFO [core.data,,,] 13304 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#1fd386c3: startup date [Wed Mar 13 12:35:27 MSK 2019]; root of context hierarchy
2019-03-13 12:35:27.268 INFO [core.data,,,] 13304 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-13 12:35:27.298 INFO [core.data,,,] 13304 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$66207a2f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-13 14:58:43,737+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-13 14:58:43,737+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'webMvcMetricsFilter' to: [/*]
2019-03-13 14:58:43,738+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'unauthorizedLogbookFilter' to: [/*]
application.yml
logging:
config: classpath:config/logging/logback.xml
pattern:
console: '%d{"yyyy-MM-dd HH:mm:ss,SSSZ"} %clr(p=%level) %clr(t=%t){yellow} %clr(l=%logger){magenta} %clr(trace-id=%X{X-B3-TraceId:-}){blue} %clr(span-id=%X{X-B3-SpanId:-}){cyan} %msg%n'
level:
org.hibernate: info
org.springframework: info
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--spring defaults-->
<include
resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-
appender.xml"/>
<!--custom configurations-->
<include resource="config/logging/file-appender.xml"/>
<!-- level configurations-->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
span-id generation occurs for an explicitly called logging method:
Logger log = loggerFactory().getLogger(this.class);
public void method(){ log.info("test"); }
First create an Rest Api and make an api request to it, if not already done.
If you are using Restemplate try creating a RestTemplate bean.
Also set the logging level to debug
logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
It's not necessary to generate a span-id for all that gets into the console log. Hit your API's then you can see the span-id and trace-id in your logs in console.
Upgrading Spring Boot 2.1.x from 2.0.x, not logging MVC mapping logs..
Spring Boot 2.0.x logs MVC Mapping at INFO level, it was very convinient and easily identifiable logs.
**Spring Boot 2.0.x**
2019-01-24 20:10:11.165 INFO [ main] s.w.s.m.m.a.RequestMappingHandlerMapping Mapped "{[/mapping2],methods=[GET]}" onto public java.lang.String com.test.controller.ControllerClass.method2()
2019-01-24 20:10:11.167 INFO [ main] s.w.s.m.m.a.RequestMappingHandlerMapping Mapped "{[/mapping1],methods=[GET]}" onto public java.lang.String com.test.controller.ControllerClass.method1()
As per Spring Boot 2.1.x documentation,
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#logging-refinements
There are no Info logs for MVC Mapping. Only summary logged as debug log.
We have to update level to TRACE to get more details.
**Spring Boot 2.0.x**
2019-01-24 20:16:08.549 TRACE 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
c.t.c.ControllerClass:
{GET /mapping1}: method1()
{GET /mapping2}: method2()
2019-01-24 20:16:08.554 TRACE 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
o.s.b.a.w.s.e.BasicErrorController:
{ /error}: error(HttpServletRequest)
{ /error, produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse)
2019-01-24 20:16:08.560 DEBUG 2516 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : 4 mappings in 'requestMappingHandlerMapping'
2019-01-24 20:16:08.584 DEBUG 2516 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Detected 0 mappings in 'beanNameHandlerMapping'
By updating web log level to DEBUG or TRACE, We get more debug logs from Spring Web and they are not useful always. Unless, TRACE level, they are not much meaningful.
2019-01-24 20:39:59.767 TRACE 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : GET "/mapping1", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
2019-01-24 20:39:59.768 TRACE 2516 --- [nio-8080-exec-5] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public java.lang.String com.test.controller.ControllerClass.method1()
2019-01-24 20:39:59.769 TRACE 2516 --- [nio-8080-exec-5] .w.s.m.m.a.ServletInvocableHandlerMethod : Arguments: []
2019-01-24 20:39:59.771 DEBUG 2516 --- [nio-8080-exec-5] m.m.a.RequestResponseBodyMethodProcessor : Using 'text/html', given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] and supported [text/plain, */*, text/plain, */*, application/json, application/*+json, application/json, application/*+json]
2019-01-24 20:39:59.771 TRACE 2516 --- [nio-8080-exec-5] m.m.a.RequestResponseBodyMethodProcessor : Writing ["Method1"]
2019-01-24 20:39:59.776 TRACE 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : No view rendering, null ModelAndView returned.
2019-01-24 20:39:59.777 DEBUG 2516 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Completed 200 OK, headers={masked}
Is it possible to get Spring log information ? and How ?
From Spring Boot 2.1 version to get RequestMappingHandlerMapping log on console try add
logging.level.org.springframework.web=trace
on application.properties file
It worked for me
Spring does not see resources folder even after adding <mvc:resources mapping="/resources/**" location="/resources"/>
I am typing localhost:8080/resources/qwerty.txt (file is created) and Dispatcher servlet is solving it by ViewResolver like "/WEB-INF/views/resources/qwerty.jsp"
Also I have found a similar project on github with "resorces" folder in "webapp" and there everything is OK. After making the same procedure like I descriped above - spring displays qwerty.txt on the screen.
This is Tomcat console:
Request #1:
TRACE 2017-04-27 15:32:23,455 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.RequestFacade#4dbf1eec
DEBUG 2017-04-27 15:32:23,456 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'di' processing GET request for [/resources/qwerty.txt]
TRACE 2017-04-27 15:32:23,460 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#444835f1] in DispatcherServlet with name 'di'
DEBUG 2017-04-27 15:32:23,463 [http-bio-8080-exec-1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /resources/qwerty.txt
TRACE 2017-04-27 15:32:23,473 [http-bio-8080-exec-1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Found 1 matching mapping(s) for [/resources/qwerty.txt] : [{[],methods=[GET]}]
DEBUG 2017-04-27 15:32:23,473 [http-bio-8080-exec-1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Returning handler method [public void web.SimpleController.index()]
DEBUG 2017-04-27 15:32:23,474 [http-bio-8080-exec-1] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'simpleController'
TRACE 2017-04-27 15:32:23,475 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter#75ad2983]
TRACE 2017-04-27 15:32:23,475 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter#1d7ba137]
TRACE 2017-04-27 15:32:23,476 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#2efb2c32]
DEBUG 2017-04-27 15:32:23,476 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/resources/qwerty.txt] is: -1
TRACE 2017-04-27 15:32:23,500 [http-bio-8080-exec-1] org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Invoking [SimpleController.index] method with arguments []
TRACE 2017-04-27 15:32:23,500 [http-bio-8080-exec-1] org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Method [index] returned [null]
DEBUG 2017-04-27 15:32:23,513 [http-bio-8080-exec-1] org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'resources/qwerty'
TRACE 2017-04-27 15:32:23,513 [http-bio-8080-exec-1] org.springframework.web.servlet.view.InternalResourceViewResolver - Cached view [resources/qwerty]
DEBUG 2017-04-27 15:32:23,513 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'resources/qwerty'; URL [/WEB-INF/views/resources/qwerty.jsp]] in DispatcherServlet with name 'di'
TRACE 2017-04-27 15:32:23,513 [http-bio-8080-exec-1] org.springframework.web.servlet.view.JstlView - Rendering view with name 'resources/qwerty' with model {} and static attributes {}
DEBUG 2017-04-27 15:32:23,521 [http-bio-8080-exec-1] org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/resources/qwerty.jsp] in InternalResourceView 'resources/qwerty'
TRACE 2017-04-27 15:32:23,527 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#4dbf1eec
DEBUG 2017-04-27 15:32:23,527 [http-bio-8080-exec-1] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
TRACE 2017-04-27 15:32:23,529 [http-bio-8080-exec-1] org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in WebApplicationContext for namespace 'di-servlet': ServletRequestHandledEvent: url=[/resources/qwerty.txt]; client=[127.0.0.1]; method=[GET]; servlet=[di]; session=[null]; user=[null]; time=[89ms]; status=[OK]
Request #2:
TRACE 2017-04-27 15:32:49,272 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Bound request context to thread: org.apache.catalina.connector.RequestFacade#4dbf1eec
DEBUG 2017-04-27 15:32:49,273 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'di' processing GET request for [/resources/qwerty.txt]
TRACE 2017-04-27 15:32:49,274 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#444835f1] in DispatcherServlet with name 'di'
DEBUG 2017-04-27 15:32:49,274 [http-bio-8080-exec-3] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /resources/qwerty.txt
TRACE 2017-04-27 15:32:49,275 [http-bio-8080-exec-3] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Found 1 matching mapping(s) for [/resources/qwerty.txt] : [{[],methods=[GET]}]
DEBUG 2017-04-27 15:32:49,275 [http-bio-8080-exec-3] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Returning handler method [public void web.SimpleController.index()]
DEBUG 2017-04-27 15:32:49,275 [http-bio-8080-exec-3] org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'simpleController'
TRACE 2017-04-27 15:32:49,276 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter#75ad2983]
TRACE 2017-04-27 15:32:49,276 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter#1d7ba137]
TRACE 2017-04-27 15:32:49,276 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#2efb2c32]
DEBUG 2017-04-27 15:32:49,276 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/resources/qwerty.txt] is: -1
TRACE 2017-04-27 15:32:49,277 [http-bio-8080-exec-3] org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Invoking [SimpleController.index] method with arguments []
TRACE 2017-04-27 15:32:49,284 [http-bio-8080-exec-3] org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Method [index] returned [null]
DEBUG 2017-04-27 15:32:49,287 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'resources/qwerty'; URL [/WEB-INF/views/resources/qwerty.jsp]] in DispatcherServlet with name 'di'
TRACE 2017-04-27 15:32:49,287 [http-bio-8080-exec-3] org.springframework.web.servlet.view.JstlView - Rendering view with name 'resources/qwerty' with model {} and static attributes {}
DEBUG 2017-04-27 15:32:49,288 [http-bio-8080-exec-3] org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/resources/qwerty.jsp] in InternalResourceView 'resources/qwerty'
TRACE 2017-04-27 15:32:49,289 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#4dbf1eec
DEBUG 2017-04-27 15:32:49,289 [http-bio-8080-exec-3] org.springframework.web.servlet.DispatcherServlet - Successfully completed request
TRACE 2017-04-27 15:32:49,289 [http-bio-8080-exec-3] org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in WebApplicationContext for namespace 'di-servlet': ServletRequestHandledEvent: url=[/resources/qwerty.txt]; client=[127.0.0.1]; method=[GET]; servlet=[di]; session=[null]; user=[null]; time=[18ms]; status=[OK]
servlet context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="controller, model, service, todo, web"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/views/"
p:suffix=".jsp"
/>
<mvc:resources mapping="/resources/**" location="/resources/"/>
<mvc:annotation-driven />
What I am doing wrong?
SOLVED:
I just changed mapping for some methods from default to their real names and everything gone
Magic
Does anyone knows why it is working in such strange way?
I'm moving from logback to log4j and I have to replicate the default configuration in Spring Boot for Log4j.
That's what I have so far, but it doesn't look like the previous one.
log4j.category.org.springframework=INFO
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
I'm trying to make it look like this:
2014-03-05 10:57:51.112 INFO 45469 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2014-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1358 ms
2014-03-05 10:57:51.698 INFO 45469 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-03-05 10:57:51.702 INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
Where is the config file so I can check the pattern and the rest of the config and see what I'm missing?
This is the pattern you are looking for:
"%d{yyyy-MM-dd HH:mm:ss.SSS} %-4p %4L --- [%15.15t] %-40.40C : %m%n%wEx"
You will get what you want.
Spring Boot Default Logback Configuration
private static final String CONSOLE_LOG_PATTERN = "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} "
+ "%clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} "
+ "%clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} "
+ "%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}";
You may find guide which gives detailed explanation about PatternLayout from org.apache.log4j.PatternLayout
There is a sample, maybe you could get some inspiration.
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd/HH:mm:ss.SSS}{UTC} [%t] %c{1} -|%-5X{requestId}|- %m%n" />
</layout>
Application log likes:
INFO 2016-07-21/12:14:49.613 [http-nio-9040-exec-9] QrCodeTestController -|29909|- BufferedImage is BufferedImage#2e5adf04: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace#4996a909 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 556 height = 776 #numDataElements 3 dataOff[0] = 6782