<div dir="ltr"><div>On Thu, Jun 27, 2013 at 12:55 AM, Jagmohan Singh <span dir="ltr"><<a href="mailto:jagmohan.singh.1@gmail.com" target="_blank">jagmohan.singh.1@gmail.com</a>></span> wrote:<br></div><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">
I have used</div><div style="font-family:arial,sans-serif;font-size:13px">logback-android-1.0.10-2.jar</div><div style="font-family:arial,sans-serif;font-size:13px">slf4j-api-1.7.5.jar</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Is it one of the stable versions that I am using? If not, is it possible for you to suggest the stable version?</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div></div></blockquote><div><br></div><div>Yes, logback-android-1.0.10-2.jar is the latest stable release.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">Also, if everything is fine, I would like to know how can I configure a Rolling file appender with rolling time of 4 hours? Is it possible?</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div></div></blockquote><div><br></div><div>Not out of the box. Currently, the TimeBasedRollingPolicy[1] rolls over files at the beginning of a time period (rather than at specific multiples). There might be an easier (or more correct) way to accomplish your goal, but I suggest overriding the period computation within the triggering policy of TimeBasedRollingPolicy.</div>
<div><br></div><div style>Here's some <b>untested</b> code (at the moment, I don't have my development environment handy to verify any of this).</div><div style><div><br></div><div style>Make this triggering-policy class available on your classpath (e.g., by compiling it into a JAR, and then putting the JAR in your libs directory at the root of your apk):</div>
<div style><br></div><div style><font face="courier new, monospace" color="#666666">package com.example;</font></div><div style><font face="courier new, monospace" color="#666666"><br></font></div><div><font face="courier new, monospace" color="#666666">public class MyTimeBasedTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {</font></div>
<div><font face="courier new, monospace" color="#666666"> private int multiple = 1;</font></div><div><font face="courier new, monospace" color="#666666"><br></font></div><div><font face="courier new, monospace" color="#666666"> public void setTimeMultiple(int multiple) {</font></div>
<div><font face="courier new, monospace" color="#666666"> this.multiple = multiple;</font></div><div><font face="courier new, monospace" color="#666666"> }</font></div><div><font face="courier new, monospace" color="#666666"><br>
</font></div><div><font face="courier new, monospace" color="#666666"> @Override</font></div><div><font face="courier new, monospace" color="#666666"> protected void computeNextCheck() {</font></div><div><font face="courier new, monospace" color="#666666"> super.computeNextCheck();</font></div>
<div><font face="courier new, monospace" color="#666666"> nextCheck *= multiple;</font></div><div><font face="courier new, monospace" color="#666666"> }</font></div><div><font face="courier new, monospace" color="#666666">}</font></div>
<div><br></div><div style>Then, in your logback.xml:</div><div style><br></div><div style><div><font face="courier new, monospace" color="#666666"><configuration></font></div><div><font face="courier new, monospace" color="#666666"> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"></font></div>
<div><font face="courier new, monospace" color="#666666"> <file>logFile.log</file></font></div><div><font face="courier new, monospace" color="#666666"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"></font></div>
<div><font face="courier new, monospace" color="#666666"> <!-- hourly rollover --></font></div><div><font face="courier new, monospace" color="#666666"> <fileNamePattern>logFile.%d{yyyy-MM-dd_HH}.log</fileNamePattern></font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> <font color="#0000ff"><!-- make that every 4 hours --></font></font></div><div><font face="courier new, monospace" color="#0000ff"> <timeBasedFileNamingAndTriggeringPolicy class="com.example.MyTimeBasedTriggeringPolicy"></font></div>
<div><font face="courier new, monospace" color="#0000ff"> <timeMultiple>4</timeMultiple></font></div><div><font face="courier new, monospace" color="#0000ff"> </timeBasedFileNamingAndTriggeringPolicy></font></div>
<div><font face="courier new, monospace" color="#666666"> </rollingPolicy></font></div><div><font face="courier new, monospace" color="#666666"><br></font></div><div><font face="courier new, monospace" color="#666666"> <encoder></font></div>
<div><font face="courier new, monospace" color="#666666"> <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern></font></div><div><font face="courier new, monospace" color="#666666"> </encoder></font></div>
<div><font face="courier new, monospace" color="#666666"> </appender> </font></div><div><font face="courier new, monospace" color="#666666"><br></font></div><div><font face="courier new, monospace" color="#666666"> <root level="DEBUG"></font></div>
<div><font face="courier new, monospace" color="#666666"> <appender-ref ref="FILE" /></font></div><div><font face="courier new, monospace" color="#666666"> </root></font></div><div><font face="courier new, monospace" color="#666666"></configuration></font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><br></font></div>[1] <a href="http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy">http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy</a></div>
</div>
</div></div></div>