java - 我在哪里可以获得 Spring Boot 默认记录器格式?

标签 java spring logging log4j spring-boot

是否可以获取 Spring boot 日志格式?我的意思是,这就是我想要的格式

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.2.RELEASE)

2015-05-14 17:01:24.340  INFO 8513 --- [           main] c.e.movies.service.ApplicationRunner     : Starting ApplicationRunner on despubuntu-ThinkPad-E420 with PID 8513 (/home/despubuntu/Documents/Workspace/example-backend-development/example-backend-development/example-backend-development-service/target/classes started by despubuntu in /home/despubuntu/Documents/Workspace/example-backend-development/example-backend-development/example-backend-development-service)
2015-05-14 17:01:24.344 DEBUG 8513 --- [           main] c.e.movies.service.ApplicationRunner     : Running with Spring Boot v1.2.2.RELEASE, Spring v4.1.6.RELEASE
2015-05-14 17:01:24.404  INFO 8513 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6524a69: startup date [Thu May 14 17:01:24 ART 2015]; root of context hierarchy
2015-05-14 17:01:25.746  INFO 8513 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-05-14 17:01:26.474  INFO 8513 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.example.movies.domain.config.PersistenceConfiguration' of type [class com.example.movies.domain.config.PersistenceConfiguration$$EnhancerBySpringCGLIB$$a8846734] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-05-14 17:01:26.677  INFO 8513 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$19cfd3dc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-05-14 17:01:26.825  INFO 8513 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-05-14 17:01:26.837  INFO 8513 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-05-14 17:01:26.843  INFO 8513 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-05-14 17:01:27.404  INFO 8513 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-05-14 17:01:27.725  INFO 8513 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2015-05-14 17:01:27.727  INFO 8513 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.20
2015-05-14 17:01:27.862  INFO 8513 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2015-05-14 17:01:27.862  INFO 8513 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3461 ms
2015-05-14 17:01:28.827  INFO 8513 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2015-05-14 17:01:28.831  INFO 8513 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-05-14 17:01:28.831  INFO 8513 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-05-14 17:01:28.888  INFO 8513 --- [           main] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: com.mysql.jdbc.Driver
2015-05-14 17:01:29.002  INFO 8513 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-05-14 17:01:30.691  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6524a69: startup date [Thu May 14 17:01:24 ART 2015]; root of context hierarchy
2015-05-14 17:01:30.773  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v3/clients],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<com.example.movies.domain.feature.commons.model.PaginatedResponse<com.example.movies.api.models.response.ClientResponseDTO>> com.example.movies.service.controller.ClientController.getClients(com.example.movies.api.models.request.model.PagingRequestDTO) throws com.example.movies.domain.exception.ValidationException
2015-05-14 17:01:30.774  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v3/clients/{clientId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<com.example.movies.api.models.response.ClientResponseDTO> com.example.movies.service.controller.ClientController.getClient(java.lang.String) throws com.example.movies.domain.exception.ValidationException
2015-05-14 17:01:30.774  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v3/clients/{clientId}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.example.movies.service.controller.ClientController.deleteClient(java.lang.String) throws com.example.movies.domain.exception.ValidationException
2015-05-14 17:01:30.774  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v3/clients],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<com.example.movies.api.models.response.ClientResponseDTO> com.example.movies.service.controller.ClientController.postClient(com.example.movies.api.models.request.ClientRequestDTO) throws com.example.movies.domain.exception.ValidationException
2015-05-14 17:01:30.774  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v3/clients/{clientId}],methods=[PUT],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<com.example.movies.api.models.response.ClientResponseDTO> com.example.movies.service.controller.ClientController.putClient(com.example.movies.api.models.request.ClientRequestDTO,java.lang.String) throws com.example.movies.domain.exception.ValidationException
2015-05-14 17:01:30.775  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/version],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.example.movies.service.controller.MainController.getVersion()
2015-05-14 17:01:30.775  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/health-check],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<com.example.movies.service.model.HealthCheck> com.example.movies.service.controller.MainController.doHealthCheck()
2015-05-14 17:01:30.779  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-05-14 17:01:30.779  INFO 8513 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2015-05-14 17:01:30.831  INFO 8513 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-05-14 17:01:30.831  INFO 8513 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-05-14 17:01:30.881  INFO 8513 --- [           main] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in exceptionsHandler
2015-05-14 17:01:30.928  INFO 8513 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-05-14 17:01:31.363  INFO 8513 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2015-05-14 17:01:31.496  INFO 8513 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2015-05-14 17:01:31.500  INFO 8513 --- [           main] c.e.movies.service.ApplicationRunner     : Started ApplicationRunner in 7.492 seconds (JVM running for 7.95)
2015-05-14 17:01:35.046  INFO 8513 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'

我想用类似的格式配置我自己的 log4j.properties,但不完全是这样。你知道我在哪里可以得到它吗?提前致谢

最佳答案

<Property name="LOG_PATTERN">[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${sys:PID} %5p [%t] --- %c{1}: %m%n</Property>.

找到了here

关于java - 我在哪里可以获得 Spring Boot 默认记录器格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30246483/

相关文章:

java - 用于创建 Lambda 的 AWS Java SDK 版本

java - 如何使 Play 中的 toJson 跳过模型中的某些字段而不使用外部库?

java - 把我所有的 bean 放在不同的文件中

spring - 如何在 Springfox Swagger 提供的 Swagger/v2/api-docs 中启用 CORS header ?

Javascript 日志记录

logging - 如何配置 Dropwizard 访问日志的位置和轮换?

java - 从另一个内部类内部的内部类访问变量

java - 从 Java 调用其中包含游标和时态表的 MS Sql 服务器存储过程?

java - Bitronix + Spring + Hibernate + 持久性

hibernate - Log4j + hibernate 5 + Weblogic 12.2.1