2

Ideally Logback would have an option to always rotate on app startup. since that feature is absent, how can I force logback to rotate on app startup? Since its vendor code, I'll have to write my own program RotateLB.java. How can I do it yet use the same logback.xml the vendor app uses. It is doing rotate when log hits 250MB.

Alan Jurgensen
  • 813
  • 11
  • 20

1 Answers1

3

This can be done by writing your own trigger, deriving ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP and overloading isTriggeringEvent().

But you will need to edit the logback.xml config file.

If not possible, you can specify an alternate config file with -Dlogback.configurationFile=...

Or, since your app is probably using the SLF4J API, you could try to remove logback and use Log4j 2 instead, which does have the option you need.

proactif
  • 11,331
  • 1
  • 17
  • 11