问题
I want to change the log level without restarting the server. I use weblogic
server. For this I thought to pass the log level from a external file (LOGBackIncludedFile.xml
) and give this file path in the logback <include file>
.
I cannot hard code the path, as the path is different in Dev
, UAT
, Production
. I want to include this file in a location inside Weblogic 12C
server. So I can change log level without touching ear
file.
<configuration scan="true" scanPeriod="30 seconds">
<include file="../../LOGBackIncludedFile.xml" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender" >
<encoder>
<pattern>%date %-5level [%logger] > %msg%n</pattern>
</encoder>
</appender>
<root level="${root.level:-DEBUG}">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Below is the LOGBackIncludedFile.xml
<included>
<property value="INFO" name="root.level"/>
</included>
when I use this existing xml I get this error.
java.io.FileNotFoundException: /usrXX/appXX/oracle/product/XXX/domains/XXXDomain/../../LOGBackIncludedFile.xml
My question is how can I set external file path dynamically in the logback.xml. The path should be to the specific weblogic
instance
. As I put the external file into my instance.
eg : /usrxx/appxx/oracle/product/XXX/domains/xxxDomain/servers/myInstance/
回答1:
Set the file path as below. This is for weblogic 12C.
<include optional="true" file="${DOMAIN_HOME}/servers/${SERVER_NAME}/LOGBackIncludedFile.xml" />
来源:https://stackoverflow.com/questions/30976870/change-log-level-in-logback-at-run-time-via-external-property-file