我从Maven的回购使用Log4j-1.2.17包。 我尝试做的包代码(我的包调用log4j的-1.2.17包)类加载问题与OSGi的
PropertyConfigurator.configure(props());
private static Properties props() {
Properties props = new Properties();
props.put("log4j.rootLogger", "INFO, R");
props.put("log4j.appender.R",
"org.apache.log4j.DailyRollingFileAppender");
props.put("log4j.appender.R.File", "logs/IhtikaClient.log");
props.put("log4j.appender.R.Append", "true");
props.put("log4j.appender.R.Threshold", "INFO");
props.put("log4j.appender.R.DatePattern", "'.'yyyy-MM-dd");
props.put("log4j.appender.R.layout", "org.apache.log4j.PatternLayout");
props.put("log4j.appender.R.layout.ConversionPattern",
//"%d{HH:mm:ss,SSS} %c - %m%n");
//"[%5p] %d{yyyy-MM-dd mm:ss} (%F:%M:%L)%n%m%n%n");
"[%5p] %d{yyyy-MM-dd mm:ss} %c (%F:%M:%L)%n%m%n");
return props;
}
但我有错误
log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable. log4j:ERROR The class "org.apache.log4j.Appender" was loaded by log4j:ERROR [[email protected]] whereas object of type log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [[email protected]]. log4j:ERROR Could not instantiate appender named "R". log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable. log4j:ERROR The class "org.apache.log4j.Appender" was loaded by log4j:ERROR [[email protected]] whereas object of type log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [[email protected]]. log4j:ERROR Could not instantiate appender named "R".
捆绑已序列
载入中.getBundleContext().installBundle("......../log4j-1.2.17.jar")
.getBundleContext().installBundle("......../I_MainForm-1.0-SNAPSHOT.jar")
如何解决此错误? 请抱歉,我的英语。 最好的问候,亚瑟。
你好。是的,这是我的错误 - 主应用程序(Loader应用程序)具有log4j lib(不是捆绑包)。在我删除这个lib之后,execption现在不显示。对不起我的英文。谢谢。 – 2012-07-30 11:13:04
@ user913766:请使用左侧的勾号接受此答案。 – 2012-07-30 17:41:20