Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
karanahuja-android opened this issue Aug 26, 2024 · 1 comment
Assignees

Comments

@karanahuja-android
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@tony19 @karanahuja-android and others