<font><font face="tahoma,sans-serif">Gah! Bitten by RTFM again...thanks for the assistance.<br clear="all"></font></font><br>--adam<br><br><a href="http://gordonizer.com" target="_blank">http://gordonizer.com</a><br><br>
<br><br><div class="gmail_quote">On Fri, Nov 9, 2012 at 12:02 AM, ceki <span dir="ltr"><<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Regarding race conditions, note that the MDC manages contextual information on a per thread basis [1].<br>
<br>
[1] <a href="http://logback.qos.ch/manual/mdc.html" target="_blank">http://logback.qos.ch/manual/<u></u>mdc.html</a><div class="im"><br>
<br>
On 09.11.2012 01:42, Adam Gordon wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
I was able to get this working using the SiftingAppender. Thanks! My<br>
request filter pulls the child app name from the URI and sets the MDC<br>
variable which yields the appropriate behavior of Spring logging to the<br>
correct log files.<br>
<br>
One final question: is this going to be subject to race conditions? If<br>
user A is using child app A at the same time as user B is using child<br>
app B, they're going to go through the same request filter so it's<br>
feasible that A's value gets set and that thread goes to do some<br>
intensive business logic (which let's say has a bunch of logging), B's<br>
thread comes in and changes the value, will A's thread suddenly switch<br>
log files?<br>
<br>
I guess the real question is when does the SiftingAppender query MDC for<br>
the value and when does it update it for the nested <appender>?<br>
<br>
--adam<br>
<br>
<a href="http://gordonizer.com" target="_blank">http://gordonizer.com</a><br>
<br>
<br>
<br></div>
On Thu, Nov 8, 2012 at 2:27 PM, ceki <<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a> <mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>>><div class="im"><br>
wrote:<br>
<br>
<br>
Have you looked at SiftingAppender [1]? If you can set an MDC<br>
variable at the beginning of a request served by each child app, the<br>
results should be rather close to what you are aiming. Give it a try.<br>
<br></div>
[1] <a href="http://logback.qos.ch/manual/__appenders.html#SiftingAppender" target="_blank">http://logback.qos.ch/manual/_<u></u>_appenders.html#<u></u>SiftingAppender</a><div><div class="h5"><br>
<<a href="http://logback.qos.ch/manual/appenders.html#SiftingAppender" target="_blank">http://logback.qos.ch/manual/<u></u>appenders.html#SiftingAppender</a><u></u>><br>
<br>
<br>
On 08.11.2012 19:54, Adam Gordon wrote:<br>
<br>
Ok, I really should have thought about what I really needed<br>
before posting.<br>
<br>
We have a "parent" GWT web application and we have children<br>
applications<br>
that are plugged into it. The children can run as standalone web<br>
applications but this is really only for development. Since<br>
each child<br>
can run independently, each has its own logback.xml file.<br>
<br>
Unfortunately, when the parent is built, the children are just<br>
JAR file<br>
dependencies and the parent also has it's own logback.xml file.<br>
<br>
Using only the parent's logback.xml file, we can configure different<br>
appenders (and thus different log files) for each of the<br>
children, but<br>
this only works because of the child namespacing (the Java package<br>
name). The parent's logback.xml defines the root logger to use the<br>
parent's appender. What this means is that if the children are<br>
using a<br>
common framework, say Spring, all the Spring logging doesn't go<br>
into the<br>
correct child's logfile, but rather the parent's.<br>
<br>
What we need is a way to either allow each child it's own,<br>
completely<br>
separate logging configuration or we need to "tag" the logging<br>
statement<br>
in the parent's log file with some name that indicates which<br>
child the<br>
message came from.<br>
<br>
I was looking at the concept of a context selector, but it<br>
wasn't clear<br>
how I'd be able to configure this to return the correct<br>
LoggingContext<br>
depending on which child issued the logging statement.<br>
<br>
Alternatively, I suppose I could add a filter which "sets" the<br>
current<br>
logging context based on the request URI - the children's<br>
request URIs<br>
are also namespaced so that each child's request URI always<br>
starts with<br>
/child_name/...<br>
<br>
Was this clear? Do anyone have any thoughts on how best to approach<br>
this problem?<br>
<br>
Thanks,<br>
<br>
--adam<br>
<br>
<a href="http://gordonizer.com" target="_blank">http://gordonizer.com</a><br>
<br>
<br>
<br>
On Thu, Nov 8, 2012 at 11:01 AM, ceki <<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a><br></div></div>
<mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>> <mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a> <mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>>>><div class="im">
<br>
<br>
wrote:<br>
<br>
<br>
Please see [1] in the docs. For your use case, you need to<br>
define<br>
the property in the context scope [2].<br>
<br>
[1]<br></div>
<a href="http://logback.qos.ch/manual/____configuration.html#____variableSubstitution" target="_blank">http://logback.qos.ch/manual/_<u></u>___configuration.html#____<u></u>variableSubstitution</a><br>
<<a href="http://logback.qos.ch/manual/__configuration.html#__variableSubstitution" target="_blank">http://logback.qos.ch/manual/<u></u>__configuration.html#__<u></u>variableSubstitution</a>><div class="im">
<br>
<br>
<<a href="http://logback.qos.ch/manual/__configuration.html#__variableSubstitution" target="_blank">http://logback.qos.ch/manual/<u></u>__configuration.html#__<u></u>variableSubstitution</a><br>
<<a href="http://logback.qos.ch/manual/configuration.html#variableSubstitution" target="_blank">http://logback.qos.ch/manual/<u></u>configuration.html#<u></u>variableSubstitution</a>>><br>
[2]<br></div>
<a href="http://logback.qos.ch/manual/____configuration.html#scopes" target="_blank">http://logback.qos.ch/manual/_<u></u>___configuration.html#scopes</a><br>
<<a href="http://logback.qos.ch/manual/__configuration.html#scopes" target="_blank">http://logback.qos.ch/manual/<u></u>__configuration.html#scopes</a>><div><div class="h5"><br>
<br>
<<a href="http://logback.qos.ch/manual/__configuration.html#scopes" target="_blank">http://logback.qos.ch/manual/<u></u>__configuration.html#scopes</a><br>
<<a href="http://logback.qos.ch/manual/configuration.html#scopes" target="_blank">http://logback.qos.ch/manual/<u></u>configuration.html#scopes</a>>><br>
<br>
<br>
On 08.11.2012 18:54, Adam Gordon wrote:<br>
<br>
The Layout chapter indicates it supports property value<br>
retrieval via<br>
%property{key} and states that the logging context is<br>
where one<br>
might<br>
put a property (along w/ System properties). I believe<br>
log4j<br>
did this<br>
w/ the <param name="key_name" value="some_value"><br>
element in the<br>
<appender> and referenced it via %properties{key_name}.<br>
<br>
I'm not seeing how to do this in Logback in XML. Would<br>
it go in the<br>
<logger> element? What's the syntax? Could someone please<br>
point me to<br>
the relevant section in the appropriate chapter of the<br>
manual?<br>
<br>
Thanks,<br>
<br>
--adam<br>
<br>
<br>
<br>
--<br>
Ceki<br>
65% of statistics are made up on the spot<br>
</div></div></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
<br>
-- <br>
Ceki<br>
65% of statistics are made up on the spot<br>
______________________________<u></u>_________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/logback-user" target="_blank">http://mailman.qos.ch/mailman/<u></u>listinfo/logback-user</a><br>
</div></div></blockquote></div><br>