Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Where to put log4j.properties
Where to put log4j.properties [message #332612] Fri, 31 October 2008 11:33 Go to next message
Christoph Jäger is currently offline Christoph JägerFriend
Messages: 14
Registered: July 2009
Junior Member
Hi,

I am trying to use log4j (via slf4j) for logging in an RCP application.
I downloaded OSGIified bundles for slf4j and log4j from SpringSource.
Everything seems to work fine (slf4j and log4j bundles / plugins are
included in my exported RCP application, and seem to be found upon
application start), only the system does not find my log4j.properties
file, so it complains that log4j is not configured properly.

I would like to include the log4j.properties file in the plugin defining
my RCP application. How can I make log4j find my log4j.properties file
this way? I tried putting it in the src directory (hoping it would be
written to the same place as the compiled class files, and be on the
classpath this way), I tried the base directory, META-INF, tried adding
it to the plugins classpath, nothing seems to work.

Any ideas?

Thanks,

Christoph Jäger
Re: Where to put log4j.properties [message #332627 is a reply to message #332612] Mon, 03 November 2008 09:21 Go to previous messageGo to next message
Christoph Jäger is currently offline Christoph JägerFriend
Messages: 14
Registered: July 2009
Junior Member
I found a solution/workaround: create a fragment containing only the
log4j.properties file, and attach this fragment to the plugin containing
the log4j libraries.

Still I would like to keep the log4j settings in my RCP application
pluging instead of creating a fragment for just this single file.

Christoph
Re: Where to put log4j.properties [message #333148 is a reply to message #332627] Wed, 26 November 2008 21:37 Go to previous message
Eclipse UserFriend
Originally posted by: stephenmccants.yahoo.com

Hi Christoph,
I ran into the same problem and found a slightly different solution that lets you keep the
log4j.properties file in the plugin that is doing the logging. I haven't tried this with different
plugins using different properties files, so I don't know if it will break down there, but I hope
not as that is my end goal.
I placed this code into my Activator and then put the log4j.properties file in the root folder for
the plugin:

Properties log4jProperties = new Properties();
URL url = this.getBundle().getResource("log4j.properties");
log4jProperties.load(url.openStream());
PropertyConfigurator.configure(log4jProperties);

Hope that helps!

--Stephen McCants

Christoph Jaeger wrote:
> I found a solution/workaround: create a fragment containing only the
> log4j.properties file, and attach this fragment to the plugin containing
> the log4j libraries.
>
> Still I would like to keep the log4j settings in my RCP application
> pluging instead of creating a fragment for just this single file.
>
> Christoph
Previous Topic:How to remove/replace the default key binding scheme
Next Topic:Show/hide view declararively
Goto Forum:
  


Current Time: Thu Apr 25 22:56:54 GMT 2024

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

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

Back to the top