|Re: Custom Log-Appender [message #591414 is a reply to message #591390]
||Wed, 21 July 2010 10:42
Registered: January 2010
First, two things:
1. Can you give yourself a name on the forum, so we can spot your entries more easily?
2. If this question is more suited to developers rather than users, you might consider putting the same question (and response) on the Virgo-Dev mailing-list.
There are some experts there who can help.
There is a (unit) test for custom appenders in the org.eclipse.virgo.medic repository, which you might like to look at.
DefaultOutputAppender and LocalizedOutputAppender are used by test class LogBackEventLoggerTests in project org.eclipse.virgo.medic.core
in (test) package org.eclipse.virgo.medic.eventlog.impl.logback. The xml used is in logback-test.xml in test/resources in the same project.
However, there are a number of other considerations for adding appenders in Virgo Kernel/Web Server.
First of all, the appenders are loaded by logback, which is deployed early on in the kernel region startup, which means that (a) the packages you use to build your appender must be imported form the same place that the medic bundle gets its packages. (Actually, it is the medic bundle that exports them, so this is reasonably easy to achieve.)
Secondly, since these packages are exported in the kernel region (and not to the user region) this means that the bundle with your appender definitions in them needs to be deployed in the kernel region.
Finally, if your appenders are 'static' and you want to guarantee them to be available from the very start, logback does the loading of appenders from its classpath and the appenders need to be on the bundle classpath of the medic bundle. Without modifying medic what you do is to put the appender code in a fragment bundle and define medic as the host fragment. The fragment bundle is then deployed by putting it in the kernel region launch list. This effectively makes it part of the kernel.
If you want to dynamically add your appender to logback (using the addAppender api on Logger) then there is no need to have a fragment bundle, just make sure that the appender is added when the appender bundle is started. In this last case, it is still necessary to put the appender code in the kernel launch list -- after the medic bundle.
Please can you report back on your experiences on Virgo Dev?
PS: I do not recommend trying to add the appender from a user region bundle, as this may have timing issues.
Steve Powell :-/
Powered by FUDForum
. Page generated in 0.03935 seconds