【发布时间】:2017-04-08 12:32:08
【问题描述】:
我尝试在我的 Eclipse 插件项目中为 log4j 使用自定义附加程序 (sentry-raven),但 log4j 找不到它。 jar 文件 (raven-log4j-7.8.6.jar) 包含缺少的附加程序 ("com.getsentry.raven.log4j.SentryAppender"),但 Eclipse 的类加载器找不到它。
这是我到目前为止所做的:
- 我将 jar 文件放在项目根目录下的 /lib 文件夹中
- 我的插件清单有
Eclipse-RegisterBuddy: org.apache.log4j、Require-Bundle: org.apache.log4j和Bundle-ClassPath: lib/, .条目
我的build.properties 看起来像
bin.includes = META-INF/,\
plugin.xml,\
.,\
lib/raven-7.8.6.jar,\
lib/raven-log4j-7.8.6.jar
我在插件的start(BundleContext context) 方法中添加了以下代码,以便更好地控制何时加载 log4j 属性文件。
URL installURL = getBundle().getEntry("/");
String installPath = Platform.asLocalURL(installURL).getFile();
PropertyConfigurator.configure(installPath +"/src/log4j.properties");
调试器越过最后一行代码时,我会立即收到以下错误。
log4j:ERROR Could not instantiate class [com.getsentry.raven.log4j.SentryAppender].
java.lang.ClassNotFoundException: com.getsentry.raven.log4j.SentryAppender cannot be found by org.apache.log4j_1.2.15.v201012070815
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
...
log4j.properties 看起来像
log4j.rootLogger=WARN, default, Sentry
log4j.appender.Sentry=com.getsentry.raven.log4j.SentryAppender
..
【问题讨论】:
标签: java eclipse-plugin log4j sentry