rbatis/fast_log

support rolling log file?

conanchen opened this issue · 3 comments

as features below?

<appender name="roll-by-size" class="org.apache.log4j.RollingFileAppender">
    <param name="file" value="target/log4j/roll-by-size/app.log" />
    <param name="MaxFileSize" value="5KB" />
    <param name="MaxBackupIndex" value="2" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n" />
        </layout>
</appender>

as features below?

<appender name="roll-by-size" class="org.apache.log4j.RollingFileAppender">
    <param name="file" value="target/log4j/roll-by-size/app.log" />
    <param name="MaxFileSize" value="5KB" />
    <param name="MaxBackupIndex" value="2" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n" />
        </layout>
</appender>

you can useFileSplitAppender
see https://github.com/rbatis/fast_log/blob/master/example/src/split_log_gz.rs

split log is not exactly the same as rolling which will only keep MaxBackupIndex files , not as many as the times goby. For I am trying to use fastlog in my desktop app which will be installed on customers' pc.

split log keep creating new log files:

❯ ls ./target/logs
temp.log temp2021_11_22T14_10_18.708108___.log
temp2021_11_22T14_09_20.262787___.log temp2021_11_22T14_10_18.708900___.log
temp2021_11_22T14_10_18.103245___.log temp2021_11_22T14_10_18.709687___.log
temp2021_11_22T14_10_18.104201___.log temp2021_11_22T14_10_18.710484___.log
temp2021_11_22T14_10_18.105310___.log temp2021_11_22T14_10_18.711351___.log
temp2021_11_22T14_10_18.106289___.log temp2021_11_22T14_10_18.712090___.log
temp2021_11_22T14_10_18.107211___.log temp2021_11_22T14_10_18.712906___.log
temp2021_11_22T14_10_18.108251___.log temp2021_11_22T14_10_18.713624___.log
temp2021_11_22T14_10_18.109182___.log temp2021_11_22T14_10_18.714458___.log
temp2021_11_22T14_10_18.110195___.log temp2021_11_22T14_10_18.715270___.log
temp2021_11_22T14_10_18.111205___.log temp2021_11_22T14_10_18.716177___.log
temp2021_11_22T14_10_18.112164___.log temp2021_11_22T14_10_18.716923___.log

ok done , just found RollingType::KeepNum(6),