Home / GitHub Page

Rotate log file

It looks like the log file .config/joplin-desktop/log.txt never gets truncated/rotated by Joplin itself (this applies probably to the other log files as well).
Do I miss something or should/can I create a logrotate conf file snippet on my Linux system myself?

Michael

Nope, you’re not missing anything. There’s currently no rotation. But I like the idea.

As for the logrotate question, I’m not sure. I don’t know, if the logger process keeps the file pointer open, and what would happen, if one were to just remove the underlying file. Maybe @laurent can answer this.

I think the file doesn’t stay open between writes so it should be fine to rotate it. Eventually we should integrate this feature to the app too as it’s true the log keeps growing without limit at the moment.

1 Like

OK, so I I’ll give it a try with the following logrotate file:

“/home/user/.config/joplin-desktop/log.txt” {
daily
rotate 7
missingok
notifempty
compress
copytruncate
}

  • option daily only for testing, weekly would be more appropriate
  • option copytruncate should handle the case if the logger process keeps the file open
  • option postrotate could be necessary if some process needs to be restarted
2 Likes

OK, it works (like expected).
I’ll use the following file as conf. file for logrotate:

/home/user/.config/joplin-desktop/log*.txt {
weekly
rotate 4
missingok
notifempty
compress
copytruncate
}

This will rotate weekly (and compress) every log file found in /home/user/.config/joplin-desktop/ and keep 4 old files.
Hint: one does not need to restart any service after putting this file into place (/etc/logrotate.d) since logrotate is not a daemon but started via crontab/systemd timer.

2 Likes