<div dir="ltr">Hi,<div>I'm working on a project that needs to have tomcat internal logs and application logs in one file.</div><div>At the moment I'm using logback to log tomcat internals with grgrzybek's project (<a href="https://github.com/grgrzybek/tomcat-slf4j-logback">https://github.com/grgrzybek/tomcat-slf4j-logback</a>) in which there is a modified version of juli that redirects calls to logback - if I didn't understand wrong) and it works really fine, I just modified a bit its logback configuration so that all 4 loggers refer to only 1 appender;</div>
<div>for my application I'm using a simple configuration that outputs to a file, uses a size and time based rolling policy: </div><div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><br>
</font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><configuration scan="true" scanPeriod="30 seconds" ></font></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; font-size: x-small; "> <appender name="MYAPP-TRIAL" class="ch.qos.logback.core.rolling.RollingFileAppender"></span></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><file>C:/Users/r0h1/workspace/TestLoggingFrameworks/logs/myapp.log</file></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><append>true</append></font></div><div><span class="Apple-tab-span" style="font-family: 'trebuchet ms', sans-serif; font-size: x-small; white-space: pre; "> </span><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; font-size: x-small; "><encoder></span></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><charset>utf-8</charset></font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><pattern>MYAPPLICATION TRIAL %d{HH:mm:ss.SSS} %-5level {%thread} [%logger{40}] : %msg%n</pattern></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span></encoder></font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><fileNamePattern>C:/Users/r0h1/workspace/TestLoggingFrameworks/logs/myapp-%d{yyyyMMdd}-%i.log.zip</fileNamePattern> </font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><maxHistory>60<!-- days --></maxHistory></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span><maxFileSize>10MB</maxFileSize> </font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span></timeBasedFileNamingAndTriggeringPolicy></font></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span></rollingPolicy></font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"><span class="Apple-tab-span" style="white-space:pre"> </span></appender></font></div>
<div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; font-size: x-small; "> <root level="info"></span></div><div><span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif; font-size: x-small; "> <appender-ref ref="MYAPP-TRIAL" /></span></div>
<div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"> </root></font></div><div><font class="Apple-style-span" size="1" face="'trebuchet ms', sans-serif"></configuration></font></div>
</div><div><br></div><div>Now I know there are 2 different approaches</div><div>1 - using prudent: but i can't use it because of its limitation with the rolling policy (in fact it doesn't work at all with this configuration)</div>
<div>2 - using <include> tag importing the appender from tomcat/conf/logback.xml (I followed logback manual, referencing the appender and so on). This approach doesn't work either, I think because the class used in the tomcat/conf/logback.xml is not logback's classic one:</div>
<div><br></div><div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><included></font></div><div> <font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"> <appender name="MYAPPTEST" class="<font class="Apple-style-span" color="#ff0000">org.apache.juli.logging.ch.qos.logback.core.rolling.RollingFileAppender</font>"></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><file>C:/Users/r0h1/workspace/TestLoggingFrameworks/logs/myapp.log</file></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><encoder></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><charset>utf-8</charset></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><pattern>%d{HH:mm:ss.SSS} %logger{0} {%thread} %level : %msg%n</pattern></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span></encoder></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><rollingPolicy class="org.apache.juli.logging.ch.qos.logback.core.rolling.TimeBasedRollingPolicy"></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><fileNamePattern>C:/Users/r0h1/workspace/TestLoggingFrameworks/logs/myapp-%d{yyyyMMdd}-%i.log.zip</fileNamePattern> </font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><maxHistory>60<!-- days --></maxHistory></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><timeBasedFileNamingAndTriggeringPolicy class="org.apache.juli.logging.ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span><maxFileSize>20MB</maxFileSize> </font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span></timeBasedFileNamingAndTriggeringPolicy></font></div>
<div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span></rollingPolicy></font></div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"><span class="Apple-tab-span" style="white-space:pre"> </span></appender></font></div>
</div><div><font class="Apple-style-span" face="'trebuchet ms', sans-serif" size="1"></included></font></div><div><br></div><div>Someone got another approach to suggest? or am I making something wrong here?</div>
<div><br></div><div>I'm using tomcat x64 7.0.22, logback 1.0.0, Win7 x64<br clear="all"><div dir="ltr"><br></div><div dir="ltr">Thanks a lot!</div><div dir="ltr"><br></div><div dir="ltr">Rohi</div><br>
</div></div>