Gzipping logfiles in rotation?

I use openHABian and after 10MB the logfiles get separated, but not gzipped. I think this is standard logrotation to zip old logs to .log.1.gz.
Can this be configured somewhere? Thanks!

I believe on raspbian it only gzips the .2 through .9 logs, leaving .1 unzipped. You can find the logrotate script in /etc/cron.daily/logrotate.

Hmm… I do already have ones up to .3 without gzip. :wink:
Thing is, the log4j is configured in /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg:

# File appender - openhab.log
log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n

I understand gzipping a log file directly is possible with RollingFileAppender (based on file size) using TimeBasedRollingPolicy. Some research brought up, that Note that TimeBasedRollingPolicy can only be configured with xml, not log4j.properties. I don’t want to rewrite the whole logging just to have it gzipped. I can live with 10*10MB backup of logs…

Thanks anyways!

That’s a pity, logback was able to do that in OH1…
Maybe this is a point to re-discuss the logger implementation of pax-logging to use. This was last discussed in https://github.com/openhab/openhab-distro/issues/14 - the outcome was to wait for Karaf 4.1.0 (which is due by the end of this year), which will bring log4j2 (that support gzipping!)

1 Like

Sorry to lead you down the rabbit hole. I was thinking about logs in general, not openHAB in specific. I just figured that the openHAB logs were rotated when logrotate runs but a quick glance at the script shows that wouldn’t be the case.

Sorry about that.

OK, it’s worth waiting for, if you could just add gzip Support on your own. :wink:

don’t be - everything’s cool! :beers: