logback / LOGBACK-1718 [Open] Timestamp in FileNamePattern not changing for SizeAndTimeBasedRollingPolicy
============================== Here's what changed in this issue in the last few minutes. This issue has been created This issue is now assigned to you. View or comment on issue using this link https://jira.qos.ch/browse/LOGBACK-1718 ============================== Issue created ------------------------------ khalil00 created this issue on 19/Jan/23 3:03 PM Summary: Timestamp in FileNamePattern not changing for SizeAndTimeBasedRollingPolicy Issue Type: Bug Affects Versions: 1.2.3 Assignee: Logback dev list Attachments: Capture d’écran 2023-01-19 145424.png Components: logback-core Created: 19/Jan/23 3:03 PM Environment: * Windows or Linux * Java 1.8 SE Labels: FileNamePattern SizeAndTimeBasedRollingPolicy timestamp Priority: Major Reporter: khalil haddad Description: Hi, I need to have the timestamp in the filename when my log file is rolled by size or day. So I set up this configuration : {code:xml} <appender name="CRTFILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${ct2s.log.dir}/cristalBPM.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <FileNamePattern>${ct2s.log.dir}/cristalBPM.archive.%d{yyyy-MM-dd}.%d{HHmmss}_%i.log</FileNamePattern> <maxFileSize>2KB</maxFileSize> </rollingPolicy> <encoder> <Pattern>[%p] %d [${ct2s.instance.name}] [%X{PROCESS}] [%t] [%c] : %m%n</Pattern> </encoder> </appender> {code} This gives me the following configuration which is good for me : {noformat} 14:51:37,202 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CRTFILE] 14:51:37,211 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@-979043153 - Archive files will be limited to [2 KB] each. 14:51:37,215 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@-979043153 - No compression will be used 14:51:37,217 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@-979043153 - Will use the pattern C:/Data/cristalBPM.archive.%d{yyyy-MM-dd}.%d{HHmmss}_%i.log for the active file 14:51:37,218 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@597517a1 - The date pattern is 'yyyy-MM-dd' from file name pattern 'C:/Data/cristalBPM.archive.%d{yyyy-MM-dd}.%d{HHmmss}_%i.log'. 14:51:37,218 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@597517a1 - Roll-over at midnight. 14:51:37,220 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@597517a1 - Setting initial period to Thu Jan 19 14:51:25 CET 2023{noformat} The problem is when the rollover occurs (because of max file size), the same timestamp is used for all the file names : cristalBPM.archive.2023-01-19.{color:#FF0000}145125{color}_0.log cristalBPM.archive.2023-01-19.{color:#FF0000}145125{color}_1.log cristalBPM.archive.2023-01-19.{color:#FF0000}145125{color}_2.log cristalBPM.archive.2023-01-19.{color:#FF0000}145125{color}_3.log *I was expecting to have a different timestamp for each file which corresponds to the moment it was created.* ============================== This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59) _______________________________________________ logback-dev mailing list logback-dev@qos.ch https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-dev