Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Log4j and OSGI
Log4j and OSGI [message #127676] Tue, 17 March 2009 21:31
Tom H is currently offline Tom HFriend
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.
Previous Topic:Equinox Logging Bundle Graduation Review
Next Topic:How To Get Example SecurePreferencesFactory to work
Goto Forum:
  


Current Time: Tue Mar 19 03:26:48 GMT 2024

Powered by FUDForum. Page generated in 0.02431 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top