<html>
<body>
<br>
Greetings,<br><br>
I have a servlet app which responds to HTTP requests.&nbsp; Each request
initiates (sometimes lengthy) processing that I would like to log to its
own uniquely named log file.&nbsp; This request log file should be
separate from the servlet's log file so that request-based log statements
aren't interleaved w/ each other making them hard to follow.&nbsp; What
approach should I use for this?&nbsp; <br><br>
I am relatively new to Logback.&nbsp; I have used programmatically
instantiated appenders in log4j to do this in the past.&nbsp; For
Logback, I have created separate configuration files for the servlet and
request log, and tried invoking a reset of the context and doConfigure()
on the Joran Configurator once when the servlet initiates, and then again
processing each request (based on a to-the-millisecond date
pattern).&nbsp; Doing this causes the servlet's log messages to go into
the request log.<br><br>
Clearly I'm doing something wrong.&nbsp;&nbsp; ere are the configuration
files that I'm using, the first for the servlet, the second for the
request logging.&nbsp; Perhaps these need to be combined into one
file?&nbsp; If so, how can I get a separate log file for each request as
its processed?<br><br>
<font face="Courier New, Courier">&lt;!-- servlet logging config file
--&gt;<br>
&lt;?<u>xml</u> version=&quot;1.0&quot;
encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;configuration scan=&quot;true&quot; scanPeriod=&quot;30
seconds&quot;&gt;<br>
&nbsp; &lt;appender name=&quot;CostingServlet&quot;
class=&quot;<u>ch</u>.<u>qos</u>.<u>logback</u>
.core.rolling.RollingFileAppender&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;!--See also
http://logback.qos.ch/manual/appenders.html#RollingFileAppender--&gt;<br>
&nbsp;&nbsp;&nbsp;
&lt;File&gt;\\host\app\logs\<u>costingservlet</u>.log&lt;/File&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;layout
class=&quot;<u>ch</u>.<u>qos</u>.<u>logback</u>
.classic.PatternLayout&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;Pattern&gt;%-17d{<u>yyyy</u>-MMM-<u>dd</u> HH:mm} %-6r [%t] %-6p
%c{3} - %m%n&lt;/Pattern&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;rollingPolicy
class=&quot;<u>ch</u>.<u>qos</u>.<u>logback</u>
.core.rolling.FixedWindowRollingPolicy&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;maxIndex&gt;10&lt;/maxIndex&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;FileNamePattern&gt;\\host\app\logs\<u>costingservlet</u>
.log.%i&lt;/FileNamePattern&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/rollingPolicy&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;triggeringPolicy
class=&quot;<u>ch</u>.<u>qos</u>.<u>logback</u>
.core.rolling.SizeBasedTriggeringPolicy&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;MaxFileSize&gt;2MB&lt;/MaxFileSize&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/triggeringPolicy&gt;<br>
&nbsp; &lt;/appender&gt;<br>
&nbsp; &lt;logger name=&quot;com.<u>bearlogic</u>.<u>servlets</u>&quot;
level=&quot;DEBUG&quot;/&gt;<br>
&nbsp; &lt;root level=&quot;debug&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;appender-<u>ref</u>
<u>ref</u>=&quot;CostingServlet&quot;/&gt;<br>
&nbsp; &lt;/root&gt;<br>
&lt;/configuration&gt;<br><br>
&lt;!-- request logging config file --&gt;<br>
&lt;?<u>xml</u> version=&quot;1.0&quot;
encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;configuration scan=&quot;true&quot; scanPeriod=&quot;30
seconds&quot;&gt;<br>
&nbsp;&nbsp; &lt;timestamp key=&quot;byMilliSecond&quot;
datePattern=&quot;yyyyMMMdd'T'HHmmssSSSS&quot; /&gt;<br>
&nbsp;&nbsp; &lt;appender name=&quot;FILE&quot;
class=&quot;<u>ch</u>.<u>qos</u>.<u>logback</u>
.core.FileAppender&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;File&gt;\\host\app\logs\<u>reqlog</u>
-${byMilliSecond}.log&lt;/File&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;layout&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;Pattern&gt;%-17d{<u>yyyy</u>-MMM-<u>dd</u> HH:mm} %-6r [%t] %-6p
%c{3} - %m%n&lt;/Pattern&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/layout&gt;<br>
&nbsp;&nbsp; &lt;/appender&gt;<br>
&nbsp;&nbsp; &lt;logger name=&quot;com.<u>bearlogic</u>.<u>rc</u>&quot;
level=&quot;DEBUG&quot; /&gt;<br>
&nbsp;&nbsp; &lt;root level=&quot;debug&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;appender-<u>ref</u>
<u>ref</u>=&quot;FILE&quot; /&gt;<br>
&nbsp;&nbsp; &lt;/root&gt;<br>
&lt;/configuration&gt;<br><br>
</font>I've read the manual, browsed through FAQ and searched the user
archives for an answer to this w/o understanding what I should be
doing.&nbsp; I can't be the first to want to do something like
this.&nbsp; Perhaps I need to use a filter of some sort?&nbsp; Any hints
or pointers on this would be greatly appreciated. <br><br>
Thanks in advance,<br><br>
-Albert<br>
</body>
</html>