Read environment variables from logback configuration file

前端 未结 6 1909
别那么骄傲
别那么骄傲 2020-12-12 23:29

I have this logback.xml file:



  

        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 00:08

    You perhaps mean MY_HOME. In your config file there is reference for OSC_HOME. See Variable substitution rules of Logback for details.

    You can pass environment variable as a Java System property and then Logback will perform the variable substitution. You can pass this as JVM option in your command line. For example:

    java -DMY_HOME=${MY_HOME} -cp ... MainClass
    

    Or You can define MY_HOME in your config file itself.

    
      
      
        ${MY_HOME}/logs/mylog.log
       
    
    

提交回复
热议问题