How to roll the log file on startup in logback

前端 未结 11 1757
梦谈多话
梦谈多话 2020-12-02 12:50

I would like to configure logback to do the following.

  • Log to a file
  • Roll the file when it reaches 50MB
  • Only keep 7 days worth of logs
  • <
11条回答
  •  青春惊慌失措
    2020-12-02 13:39

    Create your own subclass of ch.qos.logback.core.rolling.TimeBasedRollingPolicy and override its start

    public class MyPolicy
        extends ch.qos.logback.core.rolling.TimeBasedRollingPolicy
    {
    
        public void start ( )
        {
            super.start( );
            rollover( );
        }
    }
    

提交回复
热议问题