Set Logging Level in Spring Boot via Environment Variable

后端 未结 10 1068
刺人心
刺人心 2020-12-23 08:57

Should it be possible to set logging levels through environment variables alone in a Spring Boot application?

I don\'t want to use application.properties

10条回答
  •  梦毁少年i
    2020-12-23 09:39

    Yes, you can control logging level using environment variable. Here is how I have implemented for my Spring Boot application, deployed on Cloud Foundry platform.

    In you log configuration file provide placeholder for logging level to read value from environment variable. Default is INFO.

        
          
        
    

    And then, in CF deployment manifest file provide environment variable.

        applications:
        - name: my-app-name
          memory: 2048
          env:
            APP_LOGGING_LEVEL: DEBUG
    

    I hope this will help.

提交回复
热议问题