Skip to content

When Device Restart happens, some logs are not saved to file using RollingFileAppender #371

@zontyp

Description

@zontyp

Describe the bug

Hi

I am using RollingFileAppender with SizeBasedTriggeringPolicy
If I power off my device , quite a few logs are lost.
only 60 % of the logs are saved upto a point.
after that the logs are just not saved to the file.

Please guide how i can save logs upto the point at which the device is powered off.

Reproduction

power off device , logs are lost / not saved

Logs

No response

logback-android version

3.0.0

OS Version

10

What logback configuration are you using? (logback.xml or Java/Kotlin code)

logback.xml


    <appender name="DebugLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>DEBUG</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--            <level>INFO</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--            <level>VERBOSE</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--            <level>WARN</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--            <level>ERROR</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--            <level>ASSERT</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->

<!--        </filter>-->

        <file>${LOG_DIR}/debuglog.txt</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>/storage/emulated/0/Download/backup%i.txt</fileNamePattern>
            <minIndex>1</minIndex>
<!--            <maxIndex>3</maxIndex>-->
            <maxIndex>35</maxIndex>
        </rollingPolicy>
        <triggeringPolicy
            class="com.smartpay.PayNttData.utils.log.SizeBasedTriggeringPolicy">
<!--            <maxFileSize>1KB</maxFileSize>-->
            <maxFileSize>65MB</maxFileSize>
        </triggeringPolicy>

        <encoder>
            <pattern>[%date] [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
        <flushInterval>1000</flushInterval> <!-- Flush every second added now - yet to test-->
    </appender>

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions