Spring Boot 2.1 starts the root logger in debug mode until the banner prints?












0















Here's some output to give an example of what I'm talking about. The debug messages don't come solely from the Aspect4J logger, they come from several other classes as well. I've debugged the application and found that the Root logger is set to DEBUG, then later on set to INFO after the Spring Banner is printed (I don't think the banner specifically has anything to do with it).



I don't have any logging related files on my classpath unless they've been added by a dependency I'm unaware of.



I also tried setting.



# Logging
logging.level.root=INFO
logging.level.org.springframework.web=INFO
logging.level.org.hibernate=INFO


In my application.properties file but that did not help, Spring Boot 2.1 still output everything at DEBUG level until the banner printed. Any idea on how I might prevent the Root logger from coming up as DEBUG instead of INFO at the beginning would be great.



15:34:47.971 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem'
15:34:47.974 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.joran.JoranConfigurator'
15:34:47.976 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.JoranConfiguratorBase'
15:34:47.979 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.GenericConfigurator'
15:34:47.980 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.SpringBootJoranConfigurator'
15:34:47.982 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.spi.LoggerContextListener'
15:34:47.985 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.turbo.TurboFilter'
15:34:47.987 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.LogbackLoggingSystem$1'
15:34:47.988 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.LoggerConfigurationComparator'
15:34:47.989 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem$LogLevels'
15:34:48.009 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.slf4j.bridge.SLF4JBridgeHandler'

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

2018-11-21 15:34:50.094 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : Starting SpringConfig on 940e73166080 with PID 1 (/web.jar started by root in /)
2018-11-21 15:34:50.100 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : No active profile set, falling back to default profiles: default
2018-11-21 15:34:50.420 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e0ae11f: startup date [Wed Nov 21 15:34:50 EST 2018]; root of context hierarchy
2018-11-21 15:34:53.506 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.data.domain.Page com.sasquatch.technology.screening.api.JobController.listJobs(org.springframework.data.domain.Pageable))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:48) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
2018-11-21 15:34:53.525 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(com.sasquatch.technology.screening.persistence.entities.Job com.sasquatch.technology.screening.api.JobController.addJob(com.sasquatch.technology.screening.persistence.entities.Job))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:54) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
2018-11-21 15:34:53.620 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.http.ResponseEntity com.sasquatch.technology.screening.api.TestHelperController.resetDatabase())' in Type 'com.sasquatch.technology.screening.api.TestHelperController' (TestHelperController.java:45) advised by around advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (AbstractTransactionAspect.aj:66)









share|improve this question



























    0















    Here's some output to give an example of what I'm talking about. The debug messages don't come solely from the Aspect4J logger, they come from several other classes as well. I've debugged the application and found that the Root logger is set to DEBUG, then later on set to INFO after the Spring Banner is printed (I don't think the banner specifically has anything to do with it).



    I don't have any logging related files on my classpath unless they've been added by a dependency I'm unaware of.



    I also tried setting.



    # Logging
    logging.level.root=INFO
    logging.level.org.springframework.web=INFO
    logging.level.org.hibernate=INFO


    In my application.properties file but that did not help, Spring Boot 2.1 still output everything at DEBUG level until the banner printed. Any idea on how I might prevent the Root logger from coming up as DEBUG instead of INFO at the beginning would be great.



    15:34:47.971 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem'
    15:34:47.974 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.joran.JoranConfigurator'
    15:34:47.976 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.JoranConfiguratorBase'
    15:34:47.979 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.GenericConfigurator'
    15:34:47.980 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.SpringBootJoranConfigurator'
    15:34:47.982 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.spi.LoggerContextListener'
    15:34:47.985 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.turbo.TurboFilter'
    15:34:47.987 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.LogbackLoggingSystem$1'
    15:34:47.988 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.LoggerConfigurationComparator'
    15:34:47.989 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem$LogLevels'
    15:34:48.009 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.slf4j.bridge.SLF4JBridgeHandler'

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

    2018-11-21 15:34:50.094 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : Starting SpringConfig on 940e73166080 with PID 1 (/web.jar started by root in /)
    2018-11-21 15:34:50.100 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : No active profile set, falling back to default profiles: default
    2018-11-21 15:34:50.420 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e0ae11f: startup date [Wed Nov 21 15:34:50 EST 2018]; root of context hierarchy
    2018-11-21 15:34:53.506 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.data.domain.Page com.sasquatch.technology.screening.api.JobController.listJobs(org.springframework.data.domain.Pageable))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:48) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
    2018-11-21 15:34:53.525 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(com.sasquatch.technology.screening.persistence.entities.Job com.sasquatch.technology.screening.api.JobController.addJob(com.sasquatch.technology.screening.persistence.entities.Job))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:54) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
    2018-11-21 15:34:53.620 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.http.ResponseEntity com.sasquatch.technology.screening.api.TestHelperController.resetDatabase())' in Type 'com.sasquatch.technology.screening.api.TestHelperController' (TestHelperController.java:45) advised by around advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (AbstractTransactionAspect.aj:66)









    share|improve this question

























      0












      0








      0








      Here's some output to give an example of what I'm talking about. The debug messages don't come solely from the Aspect4J logger, they come from several other classes as well. I've debugged the application and found that the Root logger is set to DEBUG, then later on set to INFO after the Spring Banner is printed (I don't think the banner specifically has anything to do with it).



      I don't have any logging related files on my classpath unless they've been added by a dependency I'm unaware of.



      I also tried setting.



      # Logging
      logging.level.root=INFO
      logging.level.org.springframework.web=INFO
      logging.level.org.hibernate=INFO


      In my application.properties file but that did not help, Spring Boot 2.1 still output everything at DEBUG level until the banner printed. Any idea on how I might prevent the Root logger from coming up as DEBUG instead of INFO at the beginning would be great.



      15:34:47.971 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem'
      15:34:47.974 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.joran.JoranConfigurator'
      15:34:47.976 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.JoranConfiguratorBase'
      15:34:47.979 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.GenericConfigurator'
      15:34:47.980 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.SpringBootJoranConfigurator'
      15:34:47.982 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.spi.LoggerContextListener'
      15:34:47.985 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.turbo.TurboFilter'
      15:34:47.987 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.LogbackLoggingSystem$1'
      15:34:47.988 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.LoggerConfigurationComparator'
      15:34:47.989 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem$LogLevels'
      15:34:48.009 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.slf4j.bridge.SLF4JBridgeHandler'

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

      2018-11-21 15:34:50.094 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : Starting SpringConfig on 940e73166080 with PID 1 (/web.jar started by root in /)
      2018-11-21 15:34:50.100 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : No active profile set, falling back to default profiles: default
      2018-11-21 15:34:50.420 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e0ae11f: startup date [Wed Nov 21 15:34:50 EST 2018]; root of context hierarchy
      2018-11-21 15:34:53.506 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.data.domain.Page com.sasquatch.technology.screening.api.JobController.listJobs(org.springframework.data.domain.Pageable))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:48) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
      2018-11-21 15:34:53.525 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(com.sasquatch.technology.screening.persistence.entities.Job com.sasquatch.technology.screening.api.JobController.addJob(com.sasquatch.technology.screening.persistence.entities.Job))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:54) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
      2018-11-21 15:34:53.620 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.http.ResponseEntity com.sasquatch.technology.screening.api.TestHelperController.resetDatabase())' in Type 'com.sasquatch.technology.screening.api.TestHelperController' (TestHelperController.java:45) advised by around advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (AbstractTransactionAspect.aj:66)









      share|improve this question














      Here's some output to give an example of what I'm talking about. The debug messages don't come solely from the Aspect4J logger, they come from several other classes as well. I've debugged the application and found that the Root logger is set to DEBUG, then later on set to INFO after the Spring Banner is printed (I don't think the banner specifically has anything to do with it).



      I don't have any logging related files on my classpath unless they've been added by a dependency I'm unaware of.



      I also tried setting.



      # Logging
      logging.level.root=INFO
      logging.level.org.springframework.web=INFO
      logging.level.org.hibernate=INFO


      In my application.properties file but that did not help, Spring Boot 2.1 still output everything at DEBUG level until the banner printed. Any idea on how I might prevent the Root logger from coming up as DEBUG instead of INFO at the beginning would be great.



      15:34:47.971 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem'
      15:34:47.974 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.joran.JoranConfigurator'
      15:34:47.976 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.JoranConfiguratorBase'
      15:34:47.979 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.core.joran.GenericConfigurator'
      15:34:47.980 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.SpringBootJoranConfigurator'
      15:34:47.982 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.spi.LoggerContextListener'
      15:34:47.985 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'ch.qos.logback.classic.turbo.TurboFilter'
      15:34:47.987 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.logback.LogbackLoggingSystem$1'
      15:34:47.988 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.LoggerConfigurationComparator'
      15:34:47.989 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.springframework.boot.logging.AbstractLoggingSystem$LogLevels'
      15:34:48.009 [main] DEBUG AspectJ Weaver - [AspectJ] not weaving 'org.slf4j.bridge.SLF4JBridgeHandler'

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

      2018-11-21 15:34:50.094 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : Starting SpringConfig on 940e73166080 with PID 1 (/web.jar started by root in /)
      2018-11-21 15:34:50.100 INFO 1 --- [ main] c.s.technology.screening.SpringConfig : No active profile set, falling back to default profiles: default
      2018-11-21 15:34:50.420 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4e0ae11f: startup date [Wed Nov 21 15:34:50 EST 2018]; root of context hierarchy
      2018-11-21 15:34:53.506 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.data.domain.Page com.sasquatch.technology.screening.api.JobController.listJobs(org.springframework.data.domain.Pageable))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:48) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
      2018-11-21 15:34:53.525 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(com.sasquatch.technology.screening.persistence.entities.Job com.sasquatch.technology.screening.api.JobController.addJob(com.sasquatch.technology.screening.persistence.entities.Job))' in Type 'com.sasquatch.technology.screening.api.JobController' (JobController.java:54) advised by around advice from 'org.springframework.security.access.intercept.aspectj.aspect.AnnotationSecurityAspect' (AnnotationSecurityAspect.aj:70)
      2018-11-21 15:34:53.620 INFO 1 --- [ main] AspectJ Weaver : [AspectJ] Join point 'method-execution(org.springframework.http.ResponseEntity com.sasquatch.technology.screening.api.TestHelperController.resetDatabase())' in Type 'com.sasquatch.technology.screening.api.TestHelperController' (TestHelperController.java:45) advised by around advice from 'org.springframework.transaction.aspectj.AnnotationTransactionAspect' (AbstractTransactionAspect.aj:66)






      java spring spring-boot logging






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 20:42









      JazzepiJazzepi

      2,80643462




      2,80643462
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I was able to trace the source of the problem back to the fact that Spring does not set the logging level until it initializes and runs the implementation class for org.springframework.boot.logging.LoggingSystem. And when Logback boots up it sets the Root logger to DEBUG by default in the ch.qos.logback.classic.LoggerContext class this.root.setLevel(Level.DEBUG).



          I added the following code to a static initialization block inside of the class which contains the main() method that boots up the Spring application. The root logger gets fetched (which initializes it to DEBUG), and then cast to a Logback logger. Keep in mind this means this implementation of a fix is tied to the real logging implementation on the classpath. If I were doing all my logging through log4j or apache commons the logger I get from LoggerFactory.getLogger() would be a different type and therefore need a different cast. This cast is necessary because the SLF4J facade does not expose methods to programmatically change the logging level. Once I had a refrence to the root logger, then I just set the level. This level is eventually overridden by Spring, so I'll need to do some more plumbing if I want to automagically keep the Spring settings and my initialization block the same.



          @SpringBootApplication
          public class SpringConfig {

          static {
          ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
          }
          }





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420179%2fspring-boot-2-1-starts-the-root-logger-in-debug-mode-until-the-banner-prints%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I was able to trace the source of the problem back to the fact that Spring does not set the logging level until it initializes and runs the implementation class for org.springframework.boot.logging.LoggingSystem. And when Logback boots up it sets the Root logger to DEBUG by default in the ch.qos.logback.classic.LoggerContext class this.root.setLevel(Level.DEBUG).



            I added the following code to a static initialization block inside of the class which contains the main() method that boots up the Spring application. The root logger gets fetched (which initializes it to DEBUG), and then cast to a Logback logger. Keep in mind this means this implementation of a fix is tied to the real logging implementation on the classpath. If I were doing all my logging through log4j or apache commons the logger I get from LoggerFactory.getLogger() would be a different type and therefore need a different cast. This cast is necessary because the SLF4J facade does not expose methods to programmatically change the logging level. Once I had a refrence to the root logger, then I just set the level. This level is eventually overridden by Spring, so I'll need to do some more plumbing if I want to automagically keep the Spring settings and my initialization block the same.



            @SpringBootApplication
            public class SpringConfig {

            static {
            ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
            }
            }





            share|improve this answer




























              0














              I was able to trace the source of the problem back to the fact that Spring does not set the logging level until it initializes and runs the implementation class for org.springframework.boot.logging.LoggingSystem. And when Logback boots up it sets the Root logger to DEBUG by default in the ch.qos.logback.classic.LoggerContext class this.root.setLevel(Level.DEBUG).



              I added the following code to a static initialization block inside of the class which contains the main() method that boots up the Spring application. The root logger gets fetched (which initializes it to DEBUG), and then cast to a Logback logger. Keep in mind this means this implementation of a fix is tied to the real logging implementation on the classpath. If I were doing all my logging through log4j or apache commons the logger I get from LoggerFactory.getLogger() would be a different type and therefore need a different cast. This cast is necessary because the SLF4J facade does not expose methods to programmatically change the logging level. Once I had a refrence to the root logger, then I just set the level. This level is eventually overridden by Spring, so I'll need to do some more plumbing if I want to automagically keep the Spring settings and my initialization block the same.



              @SpringBootApplication
              public class SpringConfig {

              static {
              ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
              }
              }





              share|improve this answer


























                0












                0








                0







                I was able to trace the source of the problem back to the fact that Spring does not set the logging level until it initializes and runs the implementation class for org.springframework.boot.logging.LoggingSystem. And when Logback boots up it sets the Root logger to DEBUG by default in the ch.qos.logback.classic.LoggerContext class this.root.setLevel(Level.DEBUG).



                I added the following code to a static initialization block inside of the class which contains the main() method that boots up the Spring application. The root logger gets fetched (which initializes it to DEBUG), and then cast to a Logback logger. Keep in mind this means this implementation of a fix is tied to the real logging implementation on the classpath. If I were doing all my logging through log4j or apache commons the logger I get from LoggerFactory.getLogger() would be a different type and therefore need a different cast. This cast is necessary because the SLF4J facade does not expose methods to programmatically change the logging level. Once I had a refrence to the root logger, then I just set the level. This level is eventually overridden by Spring, so I'll need to do some more plumbing if I want to automagically keep the Spring settings and my initialization block the same.



                @SpringBootApplication
                public class SpringConfig {

                static {
                ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
                }
                }





                share|improve this answer













                I was able to trace the source of the problem back to the fact that Spring does not set the logging level until it initializes and runs the implementation class for org.springframework.boot.logging.LoggingSystem. And when Logback boots up it sets the Root logger to DEBUG by default in the ch.qos.logback.classic.LoggerContext class this.root.setLevel(Level.DEBUG).



                I added the following code to a static initialization block inside of the class which contains the main() method that boots up the Spring application. The root logger gets fetched (which initializes it to DEBUG), and then cast to a Logback logger. Keep in mind this means this implementation of a fix is tied to the real logging implementation on the classpath. If I were doing all my logging through log4j or apache commons the logger I get from LoggerFactory.getLogger() would be a different type and therefore need a different cast. This cast is necessary because the SLF4J facade does not expose methods to programmatically change the logging level. Once I had a refrence to the root logger, then I just set the level. This level is eventually overridden by Spring, so I'll need to do some more plumbing if I want to automagically keep the Spring settings and my initialization block the same.



                @SpringBootApplication
                public class SpringConfig {

                static {
                ((ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel(Level.INFO);
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 22:09









                JazzepiJazzepi

                2,80643462




                2,80643462






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420179%2fspring-boot-2-1-starts-the-root-logger-in-debug-mode-until-the-banner-prints%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Costa Masnaga

                    Fotorealismo

                    Sidney Franklin