How to use log4j in an Eclipse RCP?

十年热恋 提交于 2019-11-29 07:03:04

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

  1. Add log4j.jar in your project.
  2. Add the reference in MANIFEST.MF. Require-Bundle: org.apache.log4j;bundle-version="1.2.15"
  3. Add the reference in build.properties.

bin.includes = plugin.xml,\ META-INF/,\ .,\ lib/log4j-1.2.17.jar

  1. Use the logger in .java files.

PropertyConfigurator.configure(log4jConfPath); LOGGER.debug("STARTING APPLICATION ..");

I found this tutorial helpful. Please check - Add log4j to RCP Application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!