Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Is it possible to extend log configuration without touching serviceability.xml?
Is it possible to extend log configuration without touching serviceability.xml? [message #879187] Wed, 30 May 2012 17:42 Go to next message
Rich Mayfield is currently offline Rich MayfieldFriend
Messages: 44
Registered: August 2010
Member
According to the documentation one updates serviceability.xml to change configuration of the logback back-end.

What I'm wondering is if there is a way to extend this configuration on a per-application basis without touching that one file. I guess what I'm hoping to avoid are problems where multiple applications are reaching their grimy hands into that configuration file (and other configuration files) to do things like change "logger" settings or add "appender" implementations.

Right now, I'm touching these files to add my own appender:


    configuration/org.eclipse.equinox.simpleconfigurator/bundles.info - to add my appender implementation fragment to logback.
    configuration/org.ecilpse.virgo.kernel.userregion.properties - to allow my fragment to bleed through to the user region so that my application can change logging parameters at run time
    configuration/serviceability.xml - to register my appenders/loggers


Is there any way to avoid this? Any way to package and deploy this with my application/plan?

Thanks much in advance.
Re: Is it possible to extend log configuration without touching serviceability.xml? [message #879420 is a reply to message #879187] Thu, 31 May 2012 07:38 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Rich Mayfield wrote on Wed, 30 May 2012 18:42
According to the documentation one updates serviceability.xml to change configuration of the logback back-end.

What I'm wondering is if there is a way to extend this configuration on a per-application basis without touching that one file. I guess what I'm hoping to avoid are problems where multiple applications are reaching their grimy hands into that configuration file (and other configuration files) to do things like change "logger" settings or add "appender" implementations.

Right now, I'm touching these files to add my own appender:


  • configuration/org.eclipse.equinox.simpleconfigurator/bundles.info - to add my appender implementation fragment to logback.


I think attaching a fragment to logback is the crucial step that prevents your changes being packaged with an application. Since the logback bundles are resolved before the user region is created, there's no (workable) way to get an application fragment to attach to logback.

Unworkable ways include refreshing logback after installing a fragment bundle in the user region (but that might not work because the user region properties file does not currently support bundles being made visible from user region to kernel, also refreshing basic parts of the kernel tends to cause carnage) or adding a dynamic import to logback (with all the usual problems of unpredictable wiring plus the current limitation that the user region properties file does not support packages being made visible from user region to kernel).

It seems like the architecturally correct way to do what you want would be to implement some kind of whiteboard pattern for appenders so that appender services could be added by applications. I'm not sure how easy that would be to implement on top of standard logback, but it's a direction to explore.

Quote:


  • configuration/org.ecilpse.virgo.kernel.userregion.properties - to allow my fragment to bleed through to the user region so that my application can change logging parameters at run time
  • configuration/serviceability.xml - to register my appenders/loggers


Is there any way to avoid this? Any way to package and deploy this with my application/plan?

There are two ways the medic code supports bundle-specific logging configuration.

The first is via the service registry - see ServiceRegistryConfigurationLocator. Essentially, you define a header in your bundle something like this:
Medic-LoggingConfiguration: my.logging.config.id

and then register a LoggingConfiguration service in the service registry with the service property:
org.eclipse.virgo.medic.log.configuration.id=my.logging.config.id


The second way is to include a logback.xml (or logback-default.xml) file in your bundle which is picked up by medic's BundleResourceConfigurationLocator.

If you can design the appender as something not application-specific, then it might be reasonable to install that "globally" as you are doing and then configure it in an application-specific way.
Quote:


Thanks much in advance.
Re: Is it possible to extend log configuration without touching serviceability.xml? [message #879572 is a reply to message #879420] Thu, 31 May 2012 13:02 Go to previous messageGo to next message
Rich Mayfield is currently offline Rich MayfieldFriend
Messages: 44
Registered: August 2010
Member
That's great food for thought. Greatly appreciate it. A registering appender services sounds like the right approach - I'll have to explore that a bit.

Aside from the medic source code, is there any documentation, blogs, etc. on medic's support of bundle-specific logback configuration? I couldn't find anything except the one page covering the configuration of serviceability and diagnostics.
Re: Is it possible to extend log configuration without touching serviceability.xml? [message #879606 is a reply to message #879572] Thu, 31 May 2012 14:03 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Rich Mayfield wrote on Thu, 31 May 2012 14:02
That's great food for thought. Greatly appreciate it. A registering appender services sounds like the right approach - I'll have to explore that a bit.

Aside from the medic source code, is there any documentation, blogs, etc. on medic's support of bundle-specific logback configuration? I couldn't find anything except the one page covering the configuration of serviceability and diagnostics.

I couldn't find any documentation. There are a few tests of those features in medic. It's something we should add to the User Guide once we know it works. Feel free to send a doc patch if you dig into this. Wink
Re: Is it possible to extend log configuration without touching serviceability.xml? [message #897158 is a reply to message #879606] Sun, 22 July 2012 18:18 Go to previous messageGo to next message
Rich Mayfield is currently offline Rich MayfieldFriend
Messages: 44
Registered: August 2010
Member
For what it is worth, I am advocating a new feature to logback to help accomplish this. I have some working code examples too using the above-mentioned whiteboard pattern.

http://jira.qos.ch/browse/LOGBACK-719

Re: Is it possible to extend log configuration without touching serviceability.xml? [message #897216 is a reply to message #897158] Mon, 23 July 2012 08:45 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Great progress - thanks for the update Rich.
Previous Topic:Will Snaps work with Apache Felix
Next Topic:how to integrate spring security into virgo
Goto Forum:
  


Current Time: Thu Apr 18 01:19:30 GMT 2024

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

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

Back to the top