Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » How to detect log4j config file in bundle fragment
How to detect log4j config file in bundle fragment [message #760465] Fri, 02 December 2011 13:28 Go to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-Schwartz
Messages: 448
Registered: July 2009
Senior Member
Hello.

I am trying to OSGi-ify a third party project. This project depends on log4j for logging and I find that the log4j configuration file is not detected at runtime, which, after a little research, I discover is a typical problem with OSGi.

I have therefore created a fragment whose host bundle is com.springsource.org.apache.log4j and which contains the log4j config file under its META-INF directory. How do I make sure that the fragment is started by Virgo?

Is this even the right approach?

TIA,
B.

[Updated on: Fri, 02 December 2011 13:30]

Report message to a moderator

Re: How to detect log4j config file in bundle fragment [message #760491 is a reply to message #760465] Fri, 02 December 2011 14:43 Go to previous messageGo to next message
Lazar Kirchev is currently offline Lazar Kirchev
Messages: 28
Registered: July 2009
Location: Sofia, Bulgaria
Junior Member
Hello Barbara,

You should place your fragment in $SERVER_HOME/repository/usr and it will be attached to its host bundle.

Lazar
Re: How to detect log4j config file in bundle fragment [message #760492 is a reply to message #760465] Fri, 02 December 2011 14:46 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 273
Registered: January 2010
Senior Member
Fragment is not started per se. Virgo will scan repository for any fragments when starting a bundle and attach them to the host when starting the host.

Deploying fragment at runtime does not automatically causes host bundle to re-deploy. You have to manually call refresh on host for it to pick up new fragments.


As for the logging - Virgo is going to pipe all of the logging for commons-loggin, log4j, slf4j through logback logging bridge provided by medic.

There is a way to attach a logback.xml configuration in bundle. I think it has to be at root of the bundle. Not sure that providing log4j properties will be picked up in any case.

You can also try to modify $virgo_home/config/serviceability.xml and provide configuration in there.

Dmitry
Re: How to detect log4j config file in bundle fragment [message #760500 is a reply to message #760492] Fri, 02 December 2011 15:09 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-Schwartz
Messages: 448
Registered: July 2009
Senior Member
Thank you both.

I will experiment and report.

[Updated on: Fri, 02 December 2011 15:09]

Report message to a moderator

Re: How to detect log4j config file in bundle fragment [message #760504 is a reply to message #760465] Fri, 02 December 2011 15:52 Go to previous message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
I've seen users put log4j properties in WEB-INF/classes/log4j.properties although I can't remember off-hand whether this works. I guess the corresponding thing in a bundle would be anywhere on the bundle classpath (at the root of the bundle if bundle-classpath is not specified).

See also http://logback.qos.ch/manual/migrationFromLog4j.html.
Previous Topic:Install failed for bundle ### version '0.0.0'.
Next Topic:Virgo 3.0.1 startu failed error
Goto Forum:
  


Current Time: Fri Oct 31 04:25:31 GMT 2014

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

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