Logback不重启程序重新加载配置文件

下面配置代表不重启服务,在指定时间后重载日志配置文件

logback.xml

<configuration  scan="true" scanPeriod="30 seconds">
....
</configuration> 

配置说明:

scan: 设置为true,代表会在指定的时间内重新加载日志配置文件

scanPeriod:当scan=true时,日志配置文件会在指定的单位时间内重新加载,默认是每分钟会重载一次。

scanPeriod的配置说明:

时间单位:milliseconds, seconds, minutes , hours

eg:

5分钟: <configuration  scan="true" scanPeriod="5 minutes">

1小时:  <configuration  scan="true" scanPeriod="1 hours">

官网:https://logback.qos.ch/manual/configuration.html#autoScan

猜你喜欢

转载自ihenu.iteye.com/blog/2369271