log4j:由于 NameNotFoundException,日志未更新
我使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为您看不到日志是因为该异常。您看到异常并且日志不起作用只是巧合!
查看类路径中是否加载了多个
log4j.properties
、log4j.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.xml
s loaded in the classpath. Do not forget to look inside the classes folder and JAR files.添加
将-Dlog4j.debug=true
到运行时配置中,以查看 log4j 在启动过程中如何配置自身。
Add
-Dlog4j.debug=true
to your runtime-configuration, to see how log4j is configuring itself during startup..