<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:3.0cm 2.0cm 3.0cm 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>If you need a single destination for the whole web container, and you do not want to violate the servlet specification by writing to the file system, and the web container uses JDK14 logging and provide suitable logging facilities, you can use the slf4j-jdk bridge to forward the events to the web container log.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>In my opinion this is the correct approach for web applications.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></a></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] <b>On Behalf Of </b>Gaurav Kumar<br><b>Sent:</b> 31. oktober 2012 13:57<br><b>To:</b> logback-user@qos.ch<br><b>Subject:</b> Re: [logback-user] Jetty: How to get multiple web applications log to a common log file<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>any suggestions will be really appreciated. I am totally stuck on this.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Tue, Oct 30, 2012 at 11:39 PM, Gaurav Kumar <<a href="mailto:gaurav419@gmail.com" target="_blank">gaurav419@gmail.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal>Hi,<o:p></o:p></p><div><div><p>[Please ignore the previous email with the same subject line. That was accidentally posted.]<o:p></o:p></p><div><p><o:p> </o:p></p><p>I am using Jetty webserver and logback for logging.<o:p></o:p></p><p><br>I have a scenario with multiple Web Applications (so multiple wars into jetty/webapps dir). Each war has its own copy of logback-classic, logback-core and slf4j-api. There is a common copy of logback.xml in jetty/resources (pasted below). My intent is to maintain a logfile named "testapp.<date>.log" which should be used by all the wars for logging. Further, I want a rollover of this file on every startup. I am able to achieve this except that each war is trying to create its own version of the log file so when each war is loaded it creates its own logfile archiving the earlier logfile created by the earlier war. This continues till all wars are loaded thus creating these many log files per startup. The archived files are are named "testapp.<date>.log.<time in millisec>.<o:p></o:p></p><p>Is there a way to ask all wars to log into the same file?<o:p></o:p></p><p><o:p> </o:p></p><p><b><u>logback.xml file content:</u></b><o:p></o:p></p></div><div><p class=MsoNormal><i><configuration><br> <timestamp key="dateStr" datePattern="yyyy-MM-dd" timeReference="contextBirth"/>--><br> <timestamp key="timeStr" datePattern="HHmmssSSS" timeReference="contextBirth"/>--><br><br> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><br> <encoder><br> <pattern>%date{MMM dd}, %date{yyyy hh:mm:ss a} %class %method\(\):%line %n%level: %message%n </pattern><br> </encoder><br> </appender><br> <br> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"></i><o:p></o:p></p></div><p class=MsoNormal><i> <file>${jetty.home}/logs/testapp.${dateStr}.log</file><o:p></o:p></i></p><div><p class=MsoNormal><i><br><br> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><br> <!-- daily rollover --><o:p></o:p></i></p></div><p class=MsoNormal><i> <fileNamePattern>${jetty.home}/logs/testapp.%d{yyyy-MM-dd}.log.${timeStr}</fileNamePattern><o:p></o:p></i></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><i><br> <br> <!-- keep max 30 rolled over files --><br> <maxHistory>30</maxHistory><br> <cleanHistoryOnStart>true</cleanHistoryOnStart><o:p></o:p></i></p></div><p class=MsoNormal><i> <!-- trigger for daily rollover and every server restart --><br> <timeBasedFileNamingAndTriggeringPolicy class="utils.<b>LogbackLogTriggeringPolicy</b>"/><o:p></o:p></i></p><div><p class=MsoNormal><i><br> </rollingPolicy><br><br> <encoder><br> <pattern>%date{MMM dd}, %date{yyyy hh:mm:ss a} %class %method\(\):%line %n%level: %message%n </pattern><br> </encoder><br> </appender><br> <br> <root level="INFO"><br> <appender-ref ref="FILE" /><br> </root><br></configuration><o:p></o:p></i></p></div><p><o:p> </o:p></p><p><b>LogbackLogTriggeringPolicy.java is:</b><o:p></o:p></p><div><p class=MsoNormal><i>@NoAutoStart<br>public class LogbackLogTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {<br> @Override<br> public void start() {<br> super.start();<br> nextCheck = 0L;</i><o:p></o:p></p></div><div><p class=MsoNormal><i> isTriggeringEvent(null, null);<br> try {<br> tbrp.rollover();<br> } catch (RolloverFailure e) {<br> //Do nothing<br> }<br> }<br>}</i><o:p></o:p></p></div><p>Thanks.<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>