扫描不适用于 logback.xml [英] Scan doesn't work with logback.xml

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

问题描述

我在 src/resource/logback-spring.XML 下为我的 logback-spring.xml 工作的日志.我正在使用 Spring Boot、Maven 和 Intellij.

I have log working for my logback-spring.xml placed under src/resource/logback-spring.XML. I am using Spring Boot, Maven and Intellij.

但是当我添加扫描属性时,如果我更改日志级别,则不会反映.即使在类文件夹下的目标文件夹中,XML 文件也不会更改.我必须重建项目才能获得更新的日志.

But when I add scan property, if I change the log level, it is not reflected. The XML file isn't changed even in target folder under classes Folder. I have to rebuild the project in order to get the updated log.

我在这里错过了什么?无论如何,我至少可以绑定外部文件进行日志记录吗?

What am I missing here? Is there anyway I can at least bind the external file for logging?

下面是我的 logback-spring.xml 文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration debug="true" scan="true" scanPeriod="30 seconds">
 <include resource="org/springframework/boot/logging/logback/base.xml"/>
 <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  <encoder>
   <pattern>%d{dd-MM-yyyy} %d{HH:mm:ss.SSS} %-5relative %-5level %logger{35} - %msg%n</pattern>
 </encoder>
</appender>
<logger name="package name" level="TRACE" additivity="false">
 <appender-ref ref="CONSOLE"/>       
</logger>
 <root level="INFO">
  <appender-ref ref="CONSOLE"/>
  <appender-ref ref="FILE"/>
 </root>
</configuration>

任何指点都是有帮助的.

Any pointers is helpful.

谢谢.

推荐答案

您正在更改位于 src/main/resources 文件夹中的源 logback-spring.xml.扫描不适用于此 logback-spring.xml,而是应用于您构建的应用程序中的那个.这可以在 target 目录中,或者在通过打包应用程序生成的 war 文件中,或者如果您已将其配置为从外部位置工作.

You are changing the source logback-spring.xml located in your src/main/resources folder. Scan wont apply to this logback-spring.xml but instead to the one in your built application. This can be in the target directory, or inside the war file generated by packaging your application, or if you have configured it to work from an external location.

如果您通过 mvn spring-boot:run 运行它,请尝试在

If you are running it via mvn spring-boot:run try locating the file in

target\your-app\WEB-INF\classes\

通过更改日志级别,扫描应将其选中并反映日志记录中的更改.

there by changing a log level, scan should pick it up and reflect the change in your logging.

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

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