About the log4j log print stack record

---- encountered a log problem, similar to the student encountered, 遂 reprinted

转自:

记录下小小细节, The difference between the comma and the plus sign in the log file

Introduce the jar package:

上码:

The log information actually recorded in the log file is different, the former is

逗In the log file:

  1. 2017-06-05 10:33:56 [ERROR] [com.cooya.health.controller.category.CategoryController.updateStatus:159] | [comma] test error stack to log file

  2. java.lang.NullPointerException: null

  3. at com.cooya.health.controller.common.BaseController.getUserName(BaseController.java:48)

  4. at com.cooya.health.controller.category.CategoryController.updateStatus(CategoryController.java:155)

  5. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

  6. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

  7. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

  8. at java.lang.reflect.Method.invoke(Method.java:601)

  9. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)

  10. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)

  11. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)

  12. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832)

  13. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743)

  14. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

  15. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)

  16. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)

  17. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)

  18. at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:869)

  19. at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)

  20. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)

  21. at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

  22. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)

  23. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

  24. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)

  25. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

  26. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

  27. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

  28. at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

  29. at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

  30. at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

  31. at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

  32. at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)

  33. at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

  34. at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

  35. at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)

  36. at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)

  37. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

  38. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

  39. at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76)

  40. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

  41. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

  42. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)

  43. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

  44. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)

  45. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

  46. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)

  47. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)

  48. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)

  49. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)

  50. at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)

  51. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)

  52. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)

  53. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)

  54. at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)

  55. at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)

  56. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

  57. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

  58. at java.lang.Thread.run(Thread.java:722)

理由:

void error(String var1, Throwable var2);


The second parameter is Throwable, which is the superclass of Exception.

and if written in plus form, it is:

2017-06-05 10:33:56 [ERROR] [com.cooya.health.controller.category.CategoryController.updateStatus:160] |[ Plus] Here is a list of test error messages java.lang.NullPointerException

This is because:

void error(String var1);

is equivalent to splicing strings, so the plus sign and comma are very different for log storage.

mark A knowledge is also the basic details. The difference between Exception e

e.getMessage();

e.toString();, a graph representation.

Summary: The details determine the code gap. I didn't pay attention to it here. I feel that the comma and the plus sign are similar. I found the log file in production and found no stack information.