How to use log4j logging API in an Eclipse RCP project?
As a workaround U tried to create a new OSGI Bundle which has a log4j jars, below is the bundle structure:
I've crated a basic RCP application with a view(template) named loggingtest.I've included the bundle log4j in the dependencies tab of loggingtest project.In the Activator start method i placed the following code
Logger logger = Logger.getLogger(Activator.class);
logger.info("Info starting");
logger.warn("Warning starting");
logger.error("Error starting");
so everything is fine so far I'm able to use log4j API and half way through,i was puzzled as where to place the log4j.properties file,how can i proceed further to get a log file with all log statements.
to be more precise below is the content of my manifest file of loggingtest project
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LoggingTest
Bundle-SymbolicName: LoggingTest; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: loggingtest.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
log4j;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
There is a posting how-to setup Log4J in an OSGi-Environment. Also consider using Pax Logging when working with OSGi.
i'm using log4j with my RCP app
here's what you should do: just drop log4j plugin (you can get the 'osgified' version from Spring Bundle Repository) and then, drop it to the 'dropin' folder of your eclipse installation.
then, you should add this plugin as a dependencie of your app and on your Activator class, do the following:URL confURL = getBundle().getEntry("log4j.properties");
PropertyConfigurator.configure(FileLocator.toFileURL(confURL).getFile());
and drop this 'log4j.properties' on your root folder of your app
sorry about my english
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With