【问题标题】:Why are log4j messages not showing in the console?为什么 log4j 消息没有显示在控制台中?
【发布时间】:2012-08-14 23:50:10
【问题描述】:

我在 spring mvc 应用程序中使用 logj4。 我正在处理我在 tomcat 6 服务器上的日志,我收到以下消息:

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.

在 tom cat 服务器上的标准输出文件中。我希望在访问方法和对象时能够看到消息。这就是我使用 log4j 的方式:

class ...

private final Logger logger = Logger.getLogger(getClass()); 

logger.info("My message here");

由于某种原因,我在日志中没有看到任何消息,我看到了上述警告

【问题讨论】:

    标签: java spring debugging model-view-controller log4j


    【解决方案1】:

    听起来您还没有为您的应用程序正确设置日志记录。

    尝试查看Google search for you error 的前几个结果,尤其是问题about setting up web.xml

    【讨论】:

    • 这适用于我的标准输出,但为什么我的代码中的自定义消息没有出现在任何日志中?
    • 好吧,对不起,我现在看到他们只是出现了很多信息,我的消息介于两者之间
    猜你喜欢
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多