回溯扫描不起作用 [英] Logback scan not working

查看:331
本文介绍了回溯扫描不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使回读的自动扫描功能正常工作。看起来似乎没有改变。我添加了debug =true到section并读取它的输出,似乎都很好。它清楚地表示logback.xml文件正在每30秒监控一次更改。我为什么没有收到变化,我很失落。只是寻找一些关于如何进一步排除故障的指导。谢谢。

I am having trouble getting the auto scan functionality of logback to work. It doesn't seem to pick up the changes. I have added debug="true" to section and reading it's output, all seems fine. It clearly says the logback.xml file is being monitored for changes every 30 seconds. I am at a loss as to why changes are not being picked up. Just looking for some guidance on how I can troubleshoot this further. Thank you.

我应该提到,logback正在记录到文件中,只是对logback配置文件的更改没有被接收。

I should mention that logback is logging to the file just fine, just that changes to logback configuration file are not being picked up.

logback.xml文件

logback.xml file

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds" debug="true">

    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />  

    <property name="LOGS_PATH" value="C:\\Users\\****\\Desktop\\css_dev\\q_logs" />

    <appender name="scheduledTasksAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOGS_PATH}/scheduledTasks.log</file>

        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${LOGS_PATH}/scheduledTasks.%i.log.zip</fileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>25</maxIndex>
        </rollingPolicy>

        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>5MB</maxFileSize>
        </triggeringPolicy>

        <encoder>
            <pattern>%d{MMM/dd/yyyy HH:mm:ss} %-5level %logger{50} - %msg%n</pattern>
        </encoder>
    </appender>

    <logger name="tasks" level="warn" additivity="false">
        <appender-ref ref="scheduledTasksAppender"/>
    </logger>
</configuration>

Web应用程序启动时输出到Tomcat日志:

Output to Tomcat log when web application starts:

|-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
|-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
|-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Users/*****/Desktop/css_dev/ProjectQ/build/web/WEB-INF/classes/logback.xml]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 30 seconds
|-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:\Users\*****\Desktop\css_dev\ProjectQ\build\web\WEB-INF\classes\logback.xml]] every 30 seconds. 
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
|-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
|-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
|-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
|-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/C:/Users/*****/Desktop/css_dev/ProjectQ/build/web/WEB-INF/classes/logback.xml]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeFilter scanning period to 30 seconds
|-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:\Users\*****\Desktop\css_dev\ProjectQ\build\web\WEB-INF\classes\logback.xml]] every 30 seconds. 
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
|-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Added status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [scheduledTasksAppender]
|-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [scheduledTasksAppender]
|-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - Will use zip compression
|-INFO in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - Will use zip compression
|-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - Large window sizes are not allowed.
|-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - Large window sizes are not allowed.
|-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - MaxIndex reduced to 21
|-WARN in ch.qos.logback.core.rolling.FixedWindowRollingPolicy@298f464e - MaxIndex reduced to 21
|-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
|-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
|-INFO in ch.qos.logback.core.rolling.RollingFileAppender[scheduledTasksAppender] - Active log file name: C:\Users\*****\Desktop\css_dev\q_logs/scheduledTasks.log
|-INFO in ch.qos.logback.core.rolling.RollingFileAppender[scheduledTasksAppender] - Active log file name: C:\Users\*****\Desktop\css_dev\q_logs/scheduledTasks.log
|-INFO in ch.qos.logback.core.rolling.RollingFileAppender[scheduledTasksAppender] - File property is set to [C:\Users\*****\Desktop\css_dev\q_logs/scheduledTasks.log]
|-INFO in ch.qos.logback.core.rolling.RollingFileAppender[scheduledTasksAppender] - File property is set to [C:\Users\*****\Desktop\css_dev\q_logs/scheduledTasks.log]
|-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [tasks] to WARN
|-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [tasks] to WARN
|-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [tasks] to false
|-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [tasks] to false
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [scheduledTasksAppender] to Logger[tasks]
|-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [scheduledTasksAppender] to Logger[tasks]
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
|-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5b63e18f - Registering current configuration as safe fallback point
|-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5b63e18f - Registering current configuration as safe fallback point


推荐答案

使用logback 1.1 .7, scanPeriod 需要明确提及。否则logback将不会扫描更改。这是由于最近引入的错误( Here 是链接)。

With logback 1.1.7, scanPeriod needs to be explicitly mentioned. Otherwise logback will not scan for changes. This is due to recently introduced bug (Here is the link).

这篇关于回溯扫描不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆