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

查看:115
本文介绍了扫描不适用于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天全站免登陆