
Hi, I've currently got multiple logback-enabled servlets running under the same JVM, each in separate web contexts, and each with their own logback.xml and slf4j/logback jars in WEB-INF. Whist this works (in terms of logging), the jmxConfigurator MBean seems to only refer to one of the contexts, and has the name 'default'. I can't see the loggers listed for the other contexts. What I'd expected to see is a different MBean listed for each webapp context. Looking at the jmxConfigurator code, it seems to use the name of the logging context for the JMX name; how does this get set? Can it be set in the logback.xml? Ellis. ------------------------------------------------------------------------------------------------------------ This email (and any attachment) is confidential, may be legally privileged and is intended solely for the use of the individual or entity to whom it is addressed. If you are not the intended recipient please do not disclose, copy or take any action in reliance on it. If you have received this message in error please tell us by reply and delete all copies on your system. Although this email has been scanned for viruses you should rely on your own virus check as the sender accepts no liability for any damage arising out of any bug or virus infection. Please note that email traffic data may be monitored and that emails may be viewed for security reasons. John Wiley & Sons Limited is a private limited company registered in England with registered number 641132. Registered office address: The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ. ------------------------------------------------------------------------------------------------------------

Hello Ellis, The context name cannot be set in logback.xml. It is the job of the context selector to set the logging context's name. See http://logback.qos.ch/manual/contextSelector.html for more details. Please let us know if you need further information, Pritchard, Ellis - Ealing wrote:
Hi,
I've currently got multiple logback-enabled servlets running under the same JVM, each in separate web contexts, and each with their own logback.xml and slf4j/logback jars in WEB-INF.
Whist this works (in terms of logging), the jmxConfigurator MBean seems to only refer to one of the contexts, and has the name 'default'. I can't see the loggers listed for the other contexts.
What I'd expected to see is a different MBean listed for each webapp context.
Looking at the jmxConfigurator code, it seems to use the name of the logging context for the JMX name; how does this get set? Can it be set in the logback.xml?
Ellis. -- Ceki Gülcü

Hi! It would be really nice if the jmxConfigurator action (in logback.xml) could be configured with an explicit ObjectName. I'm in the same situation as the original poster (we're running multiple instances of the same web-application in the same servlet container). Something like: <jmxConfigurator objectNameProperty="webapp=someWebApp" /> This would yield an ObjectName as: 'ch.qos.logback.classic:Name=default,webapp=someWebApp'. This would allow each web-app to have it's own mbean instance registered with the server. My choice is either to read up on the Joran configuration API and create a custom Action that will do the kind of MBean registration that I need, or to do some voodoo in our custom Logback loader. At the moment I'm doing some funky stuff in our loader: public class ExtensionAwareLogbackConfigurationLoader implements ServletContextListener { public static class NamedContext implements Context { private Context target; private String name; public NamedContext(Context target, String name) { this.target = target; this.name = name; } public StatusManager getStatusManager() {return target.getStatusManager();} public Object getObject(String s) {return target.getObject(s);} public void putObject(String s, Object o) {target.putObject(s, o);} public String getProperty(String s) {return target.getProperty(s);} public void putProperty(String s, String s1) {target.putProperty(s, s1);} public String getName() {return this.name;} public void setName(String s) {target.setName(s);} } public void contextInitialized(ServletContextEvent event) { ApplicationExtension ext = ApplicationExtension.get(); if(ext != null){ File configurationFile = ext.getRelativePath("log/logback.xml"); if(configurationFile.exists()){ try { event.getServletContext().log("["+ ExtensionAwareLogbackConfigurationLoader.class.getSimpleName()+"]: Using external logback.xml: "+configurationFile.getAbsolutePath()); LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.putProperty("output.root", ext.getRelativePath("log/out").getAbsolutePath()); JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(new NamedContext(loggerContext, ext.getNamespace())); loggerContext.shutdownAndReset(); configurator.doConfigure(configurationFile); } catch (Exception e) { throw new RuntimeException(e); } } } } public void contextDestroyed(ServletContextEvent event) { LoggerContext loggerContext = (LoggerContext)LoggerFactory.getILoggerFactory(); loggerContext.shutdownAndReset(); } } I'm basically setting a custom name for the LoggerContext based on the current web-application context name. (The ApplicationExtension is an abstraction of a directory that contains resources per web-application == customer). Best Regards //Anders Ceki Gulcu-2 wrote:
Hello Ellis,
The context name cannot be set in logback.xml. It is the job of the context selector to set the logging context's name. See http://logback.qos.ch/manual/contextSelector.html for more details.
Please let us know if you need further information,
Pritchard, Ellis - Ealing wrote:
Hi,
I've currently got multiple logback-enabled servlets running under the same JVM, each in separate web contexts, and each with their own logback.xml and slf4j/logback jars in WEB-INF.
Whist this works (in terms of logging), the jmxConfigurator MBean seems to only refer to one of the contexts, and has the name 'default'. I can't see the loggers listed for the other contexts.
What I'd expected to see is a different MBean listed for each webapp context.
Looking at the jmxConfigurator code, it seems to use the name of the logging context for the JMX name; how does this get set? Can it be set in the logback.xml?
Ellis. -- Ceki Gülcü
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- View this message in context: http://www.nabble.com/JMXConfigurator-OName-tp18566870p18964987.html Sent from the Logback User mailing list archive at Nabble.com.

Unfortunately it looks like my delegating Context-hack in the previous post doesn't work :) Looks like the JMXConfiguratorAction uses another(!) Context-instance while executing the Action rules. I tried creating a custom Joran Action that registered the MBean with a namespace - and that worked nicely. How ever -- it is (IMO) reasonable to expect that the standard JMXConfiguratorAction would support some way to scope the ObjectName (without resorting to setting up and managing a ContextSelector for the app-server). I've created a patch for JMXConfiguratorAction that allows it to take a configuration attribute (optional) that will scope the MBean: <jmxConfigurator namespace="your_custom_tag"/> This will register the MBean with an ObjectName of "ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.ConfiguratorMBean,namespace=your_custom_tag". It is perhaps not the cleanest solution, but at least it provides some way to control the scoping of the MBean in a multi-application environment. Let me know if this is a good idea, and I will post the patch to JIRA! Best Regards //Anders Anders Engström wrote:
Hi!
It would be really nice if the jmxConfigurator action (in logback.xml) could be configured with an explicit ObjectName. I'm in the same situation as the original poster (we're running multiple instances of the same web-application in the same servlet container).
Something like:
<jmxConfigurator objectNameProperty="webapp=someWebApp" />
This would yield an ObjectName as: 'ch.qos.logback.classic:Name=default,webapp=someWebApp'.
This would allow each web-app to have it's own mbean instance registered with the server.
My choice is either to read up on the Joran configuration API and create a custom Action that will do the kind of MBean registration that I need, or to do some voodoo in our custom Logback loader. At the moment I'm doing some funky stuff in our loader:
[...]
-- View this message in context: http://www.nabble.com/JMXConfigurator-OName-tp18566870p18968701.html Sent from the Logback User mailing list archive at Nabble.com.

Please so. I quite like the idea. Anders Engström wrote:
Unfortunately it looks like my delegating Context-hack in the previous post doesn't work :)
Looks like the JMXConfiguratorAction uses another(!) Context-instance while executing the Action rules.
I tried creating a custom Joran Action that registered the MBean with a namespace - and that worked nicely.
How ever -- it is (IMO) reasonable to expect that the standard JMXConfiguratorAction would support some way to scope the ObjectName (without resorting to setting up and managing a ContextSelector for the app-server).
I've created a patch for JMXConfiguratorAction that allows it to take a configuration attribute (optional) that will scope the MBean:
<jmxConfigurator namespace="your_custom_tag"/>
This will register the MBean with an ObjectName of "ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.ConfiguratorMBean,namespace=your_custom_tag".
It is perhaps not the cleanest solution, but at least it provides some way to control the scoping of the MBean in a multi-application environment.
Let me know if this is a good idea, and I will post the patch to JIRA!
Best Regards //Anders
Anders Engström wrote:
Hi!
It would be really nice if the jmxConfigurator action (in logback.xml) could be configured with an explicit ObjectName. I'm in the same situation as the original poster (we're running multiple instances of the same web-application in the same servlet container).
Something like:
<jmxConfigurator objectNameProperty="webapp=someWebApp" />
This would yield an ObjectName as: 'ch.qos.logback.classic:Name=default,webapp=someWebApp'.
This would allow each web-app to have it's own mbean instance registered with the server.
My choice is either to read up on the Joran configuration API and create a custom Action that will do the kind of MBean registration that I need, or to do some voodoo in our custom Logback loader. At the moment I'm doing some funky stuff in our loader:
[...]
-- Ceki Gülcü QOS.ch is looking to hire talented developers located in Switzerland to work on cutting-edge software projects. If you think you are qualified, then please contact ceki@qos.ch.

Hi! 14 aug 2008 kl. 14.42 skrev Ceki Gulcu:
Please so. I quite like the idea.
Unfortunately I can not access the JIRA server :/ I get a "Bad Gateway" response from the server. I'll just go ahead and post the patch here instead. I've modified it slightly so that you also can specify an explicit 'objectName' in the tag: <jmxConfigurator/> This yields the default ObjectName of "ch.qos.logback.classic:Name=$ {nameOfContext},Type=ch.qos.logback.classic.jmx.Configurator". <jmxConfigurator namespace="foo"/> This results in "ch.qos.logback.classic:Name=$ {nameOfContext },Type=ch.qos.logback.classic.jmx.Configurator,Namespace=foo". <jmxConfigurator objectName="logback:name=foo,type=bar"/> Which obviously results in "logback:name=foo,type=bar" :) Let me know if I need to adjust the patch in any way. And also - when is the next release expected *smile*? :)
Anders Engström wrote:
[snip] I've created a patch for JMXConfiguratorAction that allows it to take a configuration attribute (optional) that will scope the MBean:
<jmxConfigurator namespace="your_custom_tag"/>
This will register the MBean with an ObjectName of "ch .qos .logback .classic:Name = default ,Type = ch .qos .logback.classic.jmx.ConfiguratorMBean,namespace=your_custom_tag".
It is perhaps not the cleanest solution, but at least it provides some way to control the scoping of the MBean in a multi-application environment.
Let me know if this is a good idea, and I will post the patch to JIRA!

Anders Engström wrote:
Hi!
14 aug 2008 kl. 14.42 skrev Ceki Gulcu:
Please so. I quite like the idea.
Unfortunately I can not access the JIRA server :/ I get a "Bad Gateway" response from the server.
Our JIRA server crashed but now it's up and running again.
I'll just go ahead and post the patch here instead.
Placing it in JIRA will ensure that your patch is not forgotten.
I've modified it slightly so that you also can specify an explicit 'objectName' in the tag:
<jmxConfigurator/>
This yields the default ObjectName of "ch.qos.logback.classic:Name=${nameOfContext},Type=ch.qos.logback.classic.jmx.Configurator".
<jmxConfigurator namespace="foo"/>
This results in "ch.qos.logback.classic:Name=${nameOfContext},Type=ch.qos.logback.classic.jmx.Configurator,Namespace=foo".
<jmxConfigurator objectName="logback:name=foo,type=bar"/>
Which obviously results in "logback:name=foo,type=bar" :)
Let me know if I need to adjust the patch in any way. And also - when is the next release expected *smile*? :)
There is no expected date. I would not want to commit to a date and later fail to uphold it. -- Ceki Gülcü

Ok - I've created a JIRA Issue: LBCLASSIC-61, and uploaded the patch there instead. Best Regards //Anders 15 aug 2008 kl. 14.42 skrev Ceki Gulcu:
Anders Engström wrote:
Hi! 14 aug 2008 kl. 14.42 skrev Ceki Gulcu:
Please so. I quite like the idea.
Unfortunately I can not access the JIRA server :/ I get a "Bad Gateway" response from the server.
Our JIRA server crashed but now it's up and running again.
I'll just go ahead and post the patch here instead.
Placing it in JIRA will ensure that your patch is not forgotten.
I've modified it slightly so that you also can specify an explicit 'objectName' in the tag: <jmxConfigurator/> This yields the default ObjectName of "ch.qos.logback.classic:Name=$ {nameOfContext},Type=ch.qos.logback.classic.jmx.Configurator". <jmxConfigurator namespace="foo"/> This results in "ch.qos.logback.classic:Name=$ {nameOfContext },Type=ch.qos.logback.classic.jmx.Configurator,Namespace=foo". <jmxConfigurator objectName="logback:name=foo,type=bar"/> Which obviously results in "logback:name=foo,type=bar" :) Let me know if I need to adjust the patch in any way. And also - when is the next release expected *smile*? :)
There is no expected date. I would not want to commit to a date and later fail to uphold it.
-- Ceki Gülcü
participants (4)
-
Anders Engström
-
Ceki Gulcu
-
Ceki Gulcu
-
Pritchard, Ellis - Ealing