java.io.FileNotFoundException log4j

时间:2013-01-30 03:19:43

标签: java

我遇到了一个问题,目前我收到了以下错误。当然这是因为用户无法访问C:这不是问题。问题是我找不到任何引用:

  • 的log4j
  • org.apache.log4j
  • org.apache.log4j.xml.DOMConfigurator

我查看了类路径,构成程序的所有类的导入,与项目相关的XML文件,我找不到对项目的任何引用。

我需要知道如何跟踪引用它的位置,以便我可以从项目中删除它。

错误示例

java.io.FileNotFoundException: c:\javalog\jhook.log (Access is denied)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:194)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:285)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502)
at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:682)
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:811)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.eglue.jhook.logging.Log4jLogger.internalInvokeStaticMethod(Log4jLogger.java:94)
at com.eglue.jhook.logging.Log4jLogger.<init>(Log4jLogger.java:19)
at com.eglue.jhook.logging.LoggerFactory.getLogger(LoggerFactory.java:22)
at com.eglue.jhook.jni.ValuePair.<clinit>(ValuePair.java:11)
at com.eglue.jhook.jni.DataEnvelope.addValue(DataEnvelope.java:52)
at com.eglue.jhook.jni.HookManager.createMMFServer(HookManager.java:169)
at com.eglue.jhook.jni.HookManager.<init>(HookManager.java:116)
at com.eglue.jhook.Hook.init(Hook.java:43)
at com.eglue.jhook.Hook.guiInitialized(Hook.java:38)
at com.sun.java.accessibility.util.EventQueueMonitor.maybeNotifyAssistiveTechnologies(EventQueueMonitor.java:233)
at com.sun.java.accessibility.util.ComponentEvtDispatchThread.run(EventQueueMonitor.java:649)

任何帮助/想法,

1 个答案:

答案 0 :(得分:0)

一旦我使用的第三方库在内部有一份log4j,我就会遇到同样的问题。

以下代码将给出log4j加载位置的位置

DOMConfigurator.class.getProtectionDomain().getCodeSource().getLocation();

通过此,您可以找到可能的配置文件的位置