1

I have installed Debian 12 on a server and installed nginx service.

However, Debian 12 don't have installed logrotate package.

I would like know the best practice for this case, if should I install this package and call its from a systemd-timer or if exists other way to rotate the nginx logs with journald.

Filipi Souza
  • 409
  • 5
  • 5

2 Answers2

3

apt install nginx logrotate

nginx ships with an example logrotate config dropped in. Even if it was not included, this is a very popular application and there are any number of articles posted for how to rotate its log files.

Package managers sometimes don't have strong dependencies on shared utility programs. In this case, every application with log files, and logrotate. Allows choice: not everyone will use it, and some will be surprised if it is on by default.

Of course, it is easy to ask for it by name: install both packages in your automation for setting up a http server.

John Mahowald
  • 36,071
0

Debian 12 uses journalctl logging. In journalctl logging, log rotation is managed by the journal system itself. The logs are stored in a binary format in the journal files, typically located in the /var/log/journal directory. The rotation process involves creating a set of indexed journal files to manage log entries efficiently.

Edit: The logrotate package in Debian primarily manages and rotates log files in the traditional system log locations. It does not directly handle the logs managed by journald, which is the journaling system used by systemd.

You can also limit the storage space that the journal takes up by editing the following options in the /etc/systemd/journald.conf file: SystemMaxUse= and RuntimeMaxUse=: the maximum amount of space that the journal should take up in a persistent storage (/var/log/journal) and in-memory storage (/run/log/journal) respectively. SystemKeepFree= and RuntimeKeepFree=: defines the percentage of disk space that should be kept free for other uses. SystemMaxFileSize= and RuntimeMaxFileSize=: controls how large journal entries should grow before being rotated. SystemMaxFiles= and RuntimeMaxFiles=: controls the maximum number of journal files to keep.

Turdie
  • 2,945