[logback-user] Configuring properties via XML

Adam Gordon adam.n.gordon at gmail.com
Thu Nov 8 19:54:17 CET 2012

Ok, I really should have thought about what I really needed before posting.

We have a "parent" GWT web application and we have children applications
that are plugged into it.  The children can run as standalone web
applications but this is really only for development.  Since each child can
run independently, each has its own logback.xml file.

Unfortunately, when the parent is built, the children are just JAR file
dependencies and the parent also has it's own logback.xml file.

Using only the parent's logback.xml file, we can configure different
appenders (and thus different log files) for each of the children, but this
only works because of the child namespacing (the Java package name).  The
parent's logback.xml defines the root logger to use the parent's appender.
 What this means is that if the children are using a common framework, say
Spring, all the Spring logging doesn't go into the correct child's logfile,
but rather the parent's.

What we need is a way to either allow each child it's own, completely
separate logging configuration or we need to "tag" the logging statement in
the parent's log file with some name that indicates which child the message
came from.

I was looking at the concept of a context selector, but it wasn't clear how
I'd be able to configure this to return the correct LoggingContext
depending on which child issued the logging statement.

Alternatively, I suppose I could add a filter which "sets" the current
logging context based on the request URI - the children's request URIs are
also namespaced so that each child's request URI always starts with

Was this clear?  Do anyone have any thoughts on how best to approach this




On Thu, Nov 8, 2012 at 11:01 AM, ceki <ceki at qos.ch> wrote:

> Please see [1] in the docs. For your use case, you need to define the
> property in the context scope [2].
> [1] http://logback.qos.ch/manual/**configuration.html#**
> variableSubstitution<http://logback.qos.ch/manual/configuration.html#variableSubstitution>
> [2] http://logback.qos.ch/manual/**configuration.html#scopes<http://logback.qos.ch/manual/configuration.html#scopes>
> On 08.11.2012 18:54, Adam Gordon wrote:
>> The Layout chapter indicates it supports property value retrieval via
>> %property{key} and states that the logging context is where one might
>> put a property (along w/ System properties).  I believe log4j did this
>> w/ the <param name="key_name" value="some_value"> element in the
>> <appender> and referenced it via %properties{key_name}.
>> I'm not seeing how to do this in Logback in XML. Would it go in the
>> <logger> element?  What's the syntax?  Could someone please point me to
>> the relevant section in the appropriate chapter of the manual?
>> Thanks,
>> --adam
>> http://gordonizer.com
> --
> Ceki
> http://twitter.com/#!/ceki
> ______________________________**_________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/**listinfo/logback-user<http://mailman.qos.ch/mailman/listinfo/logback-user>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20121108/aa50416b/attachment.html>

More information about the Logback-user mailing list