Skip to content

Used on Routes, CronTriggeringPolicy is not executed correctly #3621

Open
@Class-New

Description

@Class-New

@ppkarwasz

`

	  <Routes pattern="$${ctx:ROUTINGKEY}">
		<Route key="$${ctx:ROUTINGKEY}">
		  <RollingFile name="Rolling-default" fileName="${log.path}/common.log"
				filePattern="${log.path}/common-%d{yyyy-MM-dd}-%i.log.gz">
			<PatternLayout>
				<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %X{flowno} %t %-5p %c:%L %m%n</pattern>
			</PatternLayout>
			<Policies>
			  <SizeBasedTriggeringPolicy size="256 MB" />
			</Policies>
			<DefaultRolloverStrategy max="100"/>
		  </RollingFile>
		</Route>
		<Route>
		  <RollingFile name="Rolling-${ctx:ROUTINGKEY}" fileName="${log.path}/${ctx:ROUTINGKEY}.log"
			filePattern="${log.path}/${ctx:ROUTINGKEY}-%d{yyyy-MM-dd}-%i.log.gz">
			<PatternLayout>
				<pattern>%d{yyyy-MM-dd 'at' HH:mm:ss.SSS} %X{flowno} %t %-5p %c:%L %m%n</pattern>
			</PatternLayout>
			<Policies>
				<CronTriggeringPolicy evaluateOnStartup="true" schedule="0 0 0 * * ?">
				<SizeBasedTriggeringPolicy size="256 MB" />
			</Policies>
			<DefaultRolloverStrategy max="100"/>
		  </RollingFile>
		</Route>
	  </Routes>
	</Routing>`

I expected every time the log roll back to the specified folder, is looking forward to every day 0 am to log rolled back, but the test found that don't take effect, only the present a log time will only take effect on arrival (TimeBasedTriggeringPolicy is so, That's why I changed the CronTriggeringPolicy), and another interesting phenomenon is that schedule="0 * * * * ?" The rollback can be performed every minute. Set schedule to "0 0 * * * ?". Or schedule="0 0 0 * * ?" Can't handle it correctly

spring-boot-starter-log4j2: 2.17.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting-for-userMore information is needed from the user

    Type

    No type

    Projects

    Status

    Waiting for user

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions