Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:46:06+00:00 2026-06-14T16:46:06+00:00

I would like to roll a log after either one minute elapsed or 1MB

  • 0

I would like to roll a log after either one minute elapsed or 1MB size exceeded. But with the below configuration, only the first log is created taking the size in regard. Lets say:

myapp.2012-11-21_15-07.log (size:1026KB – 1MB)
myapp.log (size: 89KB)

Lets say that time passes (but we are still within that minute) and the log gets filled (exceeds 1MB), it won’t create another file. Another file is only created when the time is exceeded with no regard to the size.
Is this a bug or the intended feature? How do I configure this using logback? Do I need a custom implementation?

as much as I read in the current manual when I want a log rolled after either one minute elapsed or 1MB size exceeded, I would do the following configuration:

<configuration>

<appender name="file"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${catalina.base}/logs/myapp.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${catalina.base}/logs/myapp.%d{yyyy-MM-dd_HH-mm}.log</fileNamePattern>

        <maxHistory>90</maxHistory>

        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>1MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

    <encoder>
        <pattern>%-5level %date{ISO8601} [%thread]: [%class: %method] %message%n</pattern>
    </encoder>
</appender>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%-5level %date{ISO8601} [%thread]: [%class: %method] %message%n</pattern>
    </encoder>
</appender>
</appender>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%-5level %date{ISO8601} [%thread]: [%class: %method] %message%n</pattern>
    </encoder>
</appender>

<logger name="org.springframework.core">
    <level value="all"/>
</logger>

<logger name="org.springframework.beans">
    <level value="all"/>
</logger>

<logger name="org.springframework.context">
    <level value="all"/>
</logger>

<logger name="org.springframework.web">
    <level value="all"/>
</logger>
<root level="error,info,debug">
    <appender-ref ref="file"/>
    <!--   <appender-ref ref="console"/>   -->
</root>
</configuration>

The dependencies (I’m excluding commons-logging in each dependency that is using it to gain the power of logback – not shown below):

    <!-- LOGGING -->
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.6.6</version>
    </dependency>
    <!--END LOGGING-->

Some additional info:
I also tried the 1.0.7 version (the last one although not available through the central repository – had to manually include it in the local maven repository), but the same happened.
My project was using 0.9.11 version of logback and I couldn’t set up a rolling policy cause I couldn’t find any valid documentation/manual. Perhaps someone could also point out some old manuals for those who need to work with legacy dependencies.

Kind Regards,
despot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:46:08+00:00Added an answer on June 14, 2026 at 4:46 pm

    You have to set the rolling policy to use SizeAndTimeBasedFNATP

    Here is the documentation with an example

    http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedFNATP

    You are missing the %i:

    <fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
    

    Note the “%i” conversion token in addition to “%d”. Each time the current log file reaches maxFileSize before the current time period ends, it will be archived with an increasing index, starting at 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to know how to hide an div after a set of css3
I would like to get all of the images from the camera roll and
I have three gyroscope values, pitch, roll and yaw. I would like to add
After testing my Catalyst application and deciding to deploy it I would like to
I would like to design very high availability(never take server down, roll out features
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like a for loop in jquery so that: For every hover_link: show hidden
Would like someone to take a look at my script and tell me where
Would like to be able to set colors of headings and such, different font
Would like to know what a programmer should know to become a good at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.