Logging within an Eclipse RCP application is pretty easy, every Activator provides an ILog using it’s getLog() method. Though it’s a little annoying wrapping the log statements with an IStatus, using some convenience methods solves that. But what about using another logging framework, e.g. Log4J?
Nearly everybody who tried to use Log4J accross Eclipse bundles faced the context classloader problem. Usually, the Log4J binaries should be placed within a library bundle. The configuration, the log4j.properties file, though is supposed to be somewhere else within a project specific bundle. Creating a Logger instance then runs into a problem: the configuration is not visible from the library bundle. So what to do now?
A pretty elegant solution is to use a fragment containing the configuration tied to the library bundle. So the project specific configuration is separated from the framework and can be managed individually.