I want to set the initial value of branch number (%i) to 000 in log4j2.xml.

Asked 2 months ago, Updated 2 months ago, 6 views

In log4j2.xml, you can set the branch number for each log rotation by setting %i as shown on the page below.
Now, I would like to set the initial value (if it is logged out first) to 000.
Even if the tag says min=000, when the log is output for the first time, the branch number is not shaken and it is displayed as it is.
Is there any other way to achieve the above?

java apache logging

2022-09-30 13:58

1 Answers

If you look at this JIRA ticket, if you use version 2.12.0 or later, the following writing style (%i{03}) will not be able to fill in three digits:


私 I have not verified the operation.If you look at the commit history, depending on the version, it might work like %03i.It seems that the format has been changed from %03i to %i{03} to match other definitions.

2022-09-30 13:58

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.