log4j:由于 NameNotFoundException,日志未更新

发布于 2025-01-03 06:15:46 字数 1096 浏览 1 评论 0原文

我使用 Apache commons 日志记录和 log4j 进行日志记录机制。 我观察到,由于以下异常,日志没有被更新或刷新。 以下异常正在 catalina.log 中打印 请让我知道此异常如何与正在更新的日志关联

javax.naming.NameNotFoundException: Name AKADbPool is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.scivantage.middleware.util.J2EEUtil.connectToDataSource(J2EEUtil.java:48)

为什么我的应用程序日志由于上述异常而没有更新?

这是我的 Log4j.properties 文件

log4j.rootCategory=Info, A1
# A1 is a DailyRollingFileAppender
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.file=D:\\Greetings\\Ravk.log
log4j.appender.A1.datePattern='.'yyyy-MM-dd
log4j.appender.A1.append=true
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n

I am using Apache commons logging with log4j for logging Mechanism .
I observered that , the logs aren't being updated or refreshed due to the below exception .
The below Exception is being printed inside catalina.log
Please let me know how this Exception is linked with Logs being Updated

javax.naming.NameNotFoundException: Name AKADbPool is not bound in this Context
        at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.scivantage.middleware.util.J2EEUtil.connectToDataSource(J2EEUtil.java:48)

Why aren't my Application Logs aren't being updated due to above Exception ??

This is my Log4j.properties file

log4j.rootCategory=Info, A1
# A1 is a DailyRollingFileAppender
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.file=D:\\Greetings\\Ravk.log
log4j.appender.A1.datePattern='.'yyyy-MM-dd
log4j.appender.A1.append=true
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独陪着我 2025-01-10 06:15:46

我不认为您看不到日志是因为该异常。您看到异常并且日志不起作用只是巧合!

查看类路径中是否加载了多个 log4j.propertieslog4j.xml。不要忘记查看类文件夹和 JAR 文件的内部。

I don't think it is because of that exception that you're not seeing logs. It is just a coincidence that you're seeing the exception and the logs aren't working!

See if you have multiple log4j.properties, log4j.xmls loaded in the classpath. Do not forget to look inside the classes folder and JAR files.

锦爱 2025-01-10 06:15:46

添加

将-Dlog4j.debug=true

到运行时配置中,以查看 log4j 在启动过程中如何配置自身。

Add

-Dlog4j.debug=true

to your runtime-configuration, to see how log4j is configuring itself during startup..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文