回退无法找到配置文件(logback.xml) [英] Log back not able to find the configuration file (logback.xml)

查看:177
本文介绍了回退无法找到配置文件(logback.xml)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用logback作为我的新项目的日志框架。

I'm trying to use logback as the logging framework for my new project.

我将logback.xml放在 main \ resources \logback.xml

I placed the logback.xml in main\resources\logback.xml.

这些是 logback.xml 的内容file

These are the contents of logback.xml file

<configuration debug="true">

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
  <file>D:/logbacklog.log</file>
  <layout class="ch.qos.logback.classic.PatternLayout">
    <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
  </layout>
 </appender> 


    <logger name="com.myproject" level="ALL"/>


    <root level="debug">
       <appender-ref ref="FILE" />
     </root>
 </configuration>

但是,我输入的日志会在控制台中打印出来(可能是使用默认配置)。

However, logs I enter do get printed in the console (may be it's using the default configuration).

我解压了我的WAR文件,发现它在 WEB-INF \classes 中。我认为这是正确的地方。知道为什么我的配置文件没有被检测到吗?

I extracted my WAR file and found that it is in WEB-INF\classes. I think it's the proper place. Any idea why my configuration file is not getting detected ?

PS:我试图在配置文件中故意犯错(比如不正确的XML格式),但仍然没有抛出错误。

PS : I tried making mistakes intentionally in my configuration file (like improper XML format), but still no error was thrown .

这是Logback的Maven依赖。

This is the Maven dependency for Logback.

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
    </dependency>


推荐答案

JBoss AS帮助您将日志记录转移到自己的JBoss日志框架。请参阅 Logback和Jboss 7 - 不能一起使用?

JBoss AS helpfully diverts your logging to its own JBoss Log framework. See Logback and Jboss 7 - don't work together?

在我的项目中,我放弃了尝试使用Logback(测试中除外)并且只是忍受了JBoss日志记录,因为它能够做到我们需要的所有事情。

On my project, I gave up trying to use Logback (except in tests) and just put up with JBoss logging, because it was able to do everythin we needed.

这篇关于回退无法找到配置文件(logback.xml)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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