Log4j and OSGI [message #127676] |
Tue, 17 March 2009 21:31 |
Tom H Messages: 18 Registered: July 2009 |
Junior Member |
|
|
Hi experts,
I am having trouble using configuring log4j when lauching my OSGI/Eclipse
application by another application that already uses log4j.
My set up is as follows:
1. I start the original application using commandline:
java -classpath ....log4j-core.jar:... MyClass
I already use log4j jars and log4j.properties for the parent Java
application. The debug statments shows up properly from MyClass
2. Then I start my OSGI/Eclipse application programatically in the parent
application:
...
EclipseStarter.setInitialProperties(buildDefaultProps());
EclipseStarter.startup(launcherArgs, null);
EclipseStarter.run(launcherArgs);
...
3. Now inside the OSGI application code, I tried configuring the log4j
again since the debug statements inside the OSGI application produces
warnings such as:
log4j:WARN No appenders could be found for logger (my.Application).
log4j:WARN Please initialize the log4j system properly.
So I tried configuring the log4j again:
PropertyConfigurator.configure("/path_to/log4j.properties");
However, now I see more errors:
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not
assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@d1e63] whereas
object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by
[sun.misc.Launcher$AppClassLoader@12498b5].
log4j:ERROR Could not instantiate appender named "logAppender".
log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not
assignable to a "org.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR
[org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@d1e63] whereas
object of type
log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by
[sun.misc.Launcher$AppClassLoader@12498b5].
log4j:ERROR Could not instantiate appender named "trcAppender".
Can anyone advise me how to configure log4j inside my OSGI application? so
that it will use the same configuration as the one used in the normal Java
app which starts it?
Note: I know my log4j.properties works since the debug statments in the
parent Java app does appear.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.02431 seconds