简体   繁体   中英

How to off deploy DEBUG logs in Spring

I've got hundreds of logs during deploy my Spring Boot app on Tomcat 7. Example:

...
13:08:23.361 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'metaDataSourceAdvisor'
13:08:23.375 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'requestMappingHandlerAdapter'
13:08:23.375 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'mvcConversionService'
13:08:23.375 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'mvcPathMatcher'
13:08:23.375 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'mvcUrlPathHelper'
13:08:23.376 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'mvcUriComponentsContributor'
13:08:23.376 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'mvcUriComponentsContributor'
13:08:23.376 [http-apr-8080-exec-4] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration'
...

Any idea where from these logs came from and how to off DEBUG type of logs? I've tried to :

  • set in log4j properties file log4j.rootLogger=INFO , but I think logs didn't came from log4j
  • set com.my.app.level=INFO

My pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.0.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!-- deploy on tomcat -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- /deploy on tomcat -->
</dependencies>

I'm also getting DEBUG logs in console while application is working

14:31:12.034 [http-apr-8080-exec-6] DEBUG o.s.s.web.DefaultRedirectStrategy - Redirecting to 'http://localhost:8080/myapp/login'
14:31:12.034 [http-apr-8080-exec-6] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not
 be stored in HttpSession.
14:31:12.035 [http-apr-8080-exec-6] DEBUG o.s.s.w.c.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
14:31:12.038 [http-apr-8080-exec-7] DEBUG o.s.security.web.FilterChainProxy - /login at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncMan
agerIntegrationFilter'
14:31:12.039 [http-apr-8080-exec-7] DEBUG o.s.security.web.FilterChainProxy - /login at position 2 of 13 in additional filter chain; firing Filter: 'SecurityCon
textPersistenceFilter'
14:31:12.040 [http-apr-8080-exec-7] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - HttpSession returned null object for SPRING_SECURITY_CONTEXT
14:31:12.040 [http-apr-8080-exec-7] DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: org.apache.cat
alina.session.StandardSessionFacade@695ad515. A new one will be created.
14:31:12.041 [http-apr-8080-exec-7] DEBUG o.s.security.web.FilterChainProxy - /login at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWrite
rFilter'

Based on your dependencies, i can say you're using Logback , not Log4j . You can add this to your application.properties to turn off spring DEBUG logs:

logging.level.org.springframework = INFO

About the logging framework:

By default, If you use the 'Starter POMs', Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM