在第3章:配置的logback:变量替换告诉我们的各种方式来引用变量定义外,如
systemproperties和
classpath。
重要的配置是创建一个单独的文件,其中将包含所有变量。我们也可以引用类路径上的资源而不是文件。例如
logback.xml
<configuration> <property resource="resource1.properties" /> <appender name="FILE" > <!-- Here we can refer to the variable defined at the resource1.properties --> <file>${USER_HOME}/myApp.log</file> <enprer> <pattern>%msg%n</pattern> </enprer> </appender> <root level="debug"> <appender-ref ref="FILE" /> </root></configuration>外部属性文件(resource1.properties)
USER_HOME=/path/to/somewhere
请注意,
resource1.properties是的资源
classpath。
您可以在第3章:Logback配置:变量替换中参考完整版本。希望对您有所帮助。



