Hi Jonas,

In your logback.xml, the <fileNamePattern> should specify an absolute path where your application has write permissions, or else it will assume the root directory is the parent directory of the destination file (which is unlikely to be writeable). If you want the rollover files to be in the same directory as your active log file, prefix the <fileNamePattern> with the same leading path you gave in <file>.

In the following example (based on your original logback.xml), the log rolls every second in the same directory as the active file. I successfully tested this with an Android app that logged a message every 400ms.

<appender name="filelog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/log.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${LOG_DIR}/log.%d{HH-mm-ss}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
</appender>

For future reference, you can troubleshoot rollover issues by turning on debugging with the "debug" attribute for <configuration>:

    <configuration debug="true">
       ...
    </configuration>

OR run this command from an Android terminal (e.g., via adb shell), and restart your app:

    $ setprop logback.debug true

When debugging is enabled, the rollover is verbose, as seen in logcat (this is the output with your original logback.xml):

05-03 05:25:43.428: I/com.example.MainActivity(1567): hello world
05-03 05:25:43.830: I/com.example.MainActivity(1567): hello world
05-03 05:25:44.226: I/com.example.MainActivity(1567): hello world
05-03 05:25:44.236: I/System.out(1567): 05:25:44,235 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Elapsed period: Fri May 03 05:25:43 GMT 2013
05-03 05:25:44.246: I/System.out(1567): 05:25:44,243 |-INFO in c.q.l.co.rolling.helper.RenameUtil - Renaming file [/sdcard/logback/log.log] to [log.05-25-43.log]
05-03 05:25:44.246: I/System.out(1567): 05:25:44,251 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Failed to rename file [/sdcard/logback/log.log] to [log.05-25-43.log].
05-03 05:25:44.266: I/System.out(1567): 05:25:44,259 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Please consider leaving the [file] option of RollingFileAppender empty.
05-03 05:25:44.266: I/System.out(1567): 05:25:44,267 |-WARN in c.q.l.co.rolling.helper.RenameUtil - See also http://logback.qos.ch/codes.html#renamingError


Hope that helps,
Tony



On Thu, May 2, 2013 at 1:04 AM, Jonas Schmid <jonas.schmid@gmail.com> wrote:
Hi there,

I am trying to use the time based rolling configuration for my android app.

I got my configuration from the doc (http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy) but it does not seem to work on my app.

Please find enclosed my config file.

The file does not roll and everything goes to log.log.

To try it out I changed the date on my phone. I took care of killing the app before doing so.
I also set the time to 23h59 then launched my app and waited, but it did not work either.

What did I do wrong?
Thanks

Jonas


_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user