You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "BARSZCZ, KRZYSZTOF" <kr...@lhsystems.com> on 2020/09/18 12:11:02 UTC

Log rotation - remove files older than 5 days

Hi,
We are trying to achieve that only Artemis logs from the last 5 days will be kept (older logfiles should be removed). The functionality provided by RollingFileAppender from logback http://logback.qos.ch/manual/appenders.html#RollingFileAppender is completely sufficient (produce new file every day, set history size to 5). Could you provide some tips how to use this class or achieve similar functionality? The documentation https://activemq.apache.org/components/artemis/documentation/latest/logging.html says the handler has to extend `java.util.logging.Handler`, which RollingFileAppender doesn’t. Is there a way to configure Artemis to e.g. use slf4j and logback?

Best wishes,
Krzysztof Barszcz



Lufthansa Systems Poland sp. z o.o., Siedziba: Aleja Grunwaldzka 415, 80-309 Gdańsk, Prezes Zarządu: Dariusz Przywara
Sad Rejonowy Gdańsk-Północ w Gdańsku, VII Wydział Gospodarczy Krajowego Rejestru Sadowego, nr KRS: 0000083575, NIP: 583-24-68-348, Regon: 191499280 kapitał zakładowy 200.000 zł.
---
Lufthansa Systems Poland Sp. z o.o., Corporate Headquarters: Aleja Grunwaldzka 415, 80-309 Gdansk, President of the Management Board: Dariusz Przywara
Registration: the District Court of Gdansk-Polnoc in Gdansk, VII Commercial Department of the National Court Register, KRS no: 0000083575, VAT UE no: PL 583-24-68-348, REGON no: 191499280, Initial capital 200.000 PLN


Re: Log rotation - remove files older than 5 days

Posted by Robbie Gemmell <ro...@gmail.com>.
I dont know if there is already a simple a way to use Logback
directly/indirectly (without e.g implementing such a handler), but in
terms of log rotation I see from etc/logging.properties that the
config shows handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
is the default handler used, and having a quick google and peek at the
source tree at https://github.com/jboss-logging/jboss-logmanager/blob/2.1.10.Final/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java#L130
suggests that it picks the smallest element (year, month, week, etc)
from the supplied suffix as its rotation period. While there I spotted
there looks to be an extended version of the handler for doing
size-based rolling too that also incorporates a 'max backups' ability
https://github.com/jboss-logging/jboss-logmanager/blob/2.1.10.Final/src/main/java/org/jboss/logmanager/handlers/PeriodicSizeRotatingFileHandler.java#L207,
which may be of interest to you...though I guess you might also need
to e.g set a large file size to make it more likely only the period
influences the rollover.


On Fri, 18 Sep 2020 at 13:11, BARSZCZ, KRZYSZTOF
<kr...@lhsystems.com> wrote:
>
> Hi,
> We are trying to achieve that only Artemis logs from the last 5 days will be kept (older logfiles should be removed). The functionality provided by RollingFileAppender from logback http://logback.qos.ch/manual/appenders.html#RollingFileAppender is completely sufficient (produce new file every day, set history size to 5). Could you provide some tips how to use this class or achieve similar functionality? The documentation https://activemq.apache.org/components/artemis/documentation/latest/logging.html says the handler has to extend `java.util.logging.Handler`, which RollingFileAppender doesn’t. Is there a way to configure Artemis to e.g. use slf4j and logback?
>
> Best wishes,
> Krzysztof Barszcz
>
>
>
> Lufthansa Systems Poland sp. z o.o., Siedziba: Aleja Grunwaldzka 415, 80-309 Gdańsk, Prezes Zarządu: Dariusz Przywara
> Sad Rejonowy Gdańsk-Północ w Gdańsku, VII Wydział Gospodarczy Krajowego Rejestru Sadowego, nr KRS: 0000083575, NIP: 583-24-68-348, Regon: 191499280 kapitał zakładowy 200.000 zł.
> ---
> Lufthansa Systems Poland Sp. z o.o., Corporate Headquarters: Aleja Grunwaldzka 415, 80-309 Gdansk, President of the Management Board: Dariusz Przywara
> Registration: the District Court of Gdansk-Polnoc in Gdansk, VII Commercial Department of the National Court Register, KRS no: 0000083575, VAT UE no: PL 583-24-68-348, REGON no: 191499280, Initial capital 200.000 PLN
>