Rotating landscape-client logs

Hello,

We are using the Landscape client snap and noticed that its log files never rotate, which could lead to the device running out of storage over time. This behavior differs from the Debian package, where logrotate is used along with a SIGUSR1 signal sent to the Landscape service to trigger log rotation. (Refer to this file for details.)

We would like to request a mechanism for log rotation in the Landscape client snap.

landscape-client version

Name              Version  Rev  Tracking       Publisher   Notes
landscape-client  24.08    334  latest/stable  canonicalāœ“  -

Example log file size(Although its on DEBUG level, we still would like to rotate)

-rw-r--r-- 1 root root 6.2G Jan  7 07:29 broker.log
-rw-r--r-- 1 root root 8.1M Jan  7 07:37 manager.log
-rw-r--r-- 1 root root  15M Jan  7 07:35 monitor.log
-rw-r--r-- 1 root root 305K Jan  2 13:35 watchdog.log

Thanks.

Hey @mikecw , do you have any idea about this?

Hi @aliihsan,

Can have a look. Seems sensible a request so I’ll stick it in the backlog. Code base is the same between deb and snap so probably just need to propagate that signal into the snap somehow.

UbuntuCore does not ship logrotate since snaps usually log through journald which has internal ways of dealing with this.

If the snap writes its own logs to its own space you will likely need to stage logrotate into it and ship a systemd timer to have it run regularly with a specific config to rotate the logs in the snap owned space …

1 Like

Hi @aliihsan,

The request seems sensible - I’ll stick it in the backlog and we’ll have a look. As @ogra says we may have to look at options as we want to keep the snap and deb codebase the same as much as possible.

1 Like

Thanks a lot, both of you guys, I will be waiting for it.

@aliihsan - please feel free to have a look and see if it is sufficient for your requirements.

1 Like

This is now approved and is currently in the EDGE snap channel. I’ll get some docs done for it shortly.

Thanks a lot for bringing it up quickly, I appreciated it.

I will test it soon.

Hey @mikecw, I finally had a chance to test this implementation, but it seems something is not happy.

I checked the logs and sizes before and after the timer was supposed to expire. It seems log rotation didn’t happen.

I am using version 22/edge revision 388.

Although the snap logs stated that the service is started and deactivated in planned time frame.

2025-04-06T02:07:16Z systemd[1]: Started Service for snap application landscape-client.logrotate.
2025-04-06T02:07:16Z systemd[1]: snap.landscape-client.logrotate.service: Deactivated successfully.

Does it require being size limited before rotating? I have checked the config file you provided in the above commit, but couldn’t find it. Any idea?

Thanks.

Hmmm dunno.

@st3v3nmw - can you please have a look at this? Thanks

Yep… I’ll provide feedback soon.