Logback不会将日志写入文件中,但会写入控制台 [英] Logback does not write log into the file but console

查看:1996
本文介绍了Logback不会将日志写入文件中,但会写入控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么logback将日志写到控制台中,请帮忙谢谢.

I do not know why logback writes log into the console, please help thanks.

<configuration debug="true" scan="true">



    <appender name="FILE"
        class="ch.qos.logback.core.rolling.RollingFileAppender">

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>/log/%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
                %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="FILE" />
        <includeCallerData>true</includeCallerData>
    </appender>

    <root level="INFO">
        <appender-ref ref="ASYNC" />
    </root>

    <root level="ERROR">
        <appender-ref ref="ASYNC" />
    </root>
</configuration>

推荐答案

您已将附加程序命名为相同的ref ="FILE",并将根级别记录程序命名为"ASYNC"

You have named both your appender the same ref="FILE" and your root level loggers as "ASYNC"

这篇关于Logback不会将日志写入文件中,但会写入控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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