Operations grimoire/Logs: Difference between revisions

From Nasqueron Agora
Blanked the page
Tag: Blanking
No edit summary
Tag: Manual revert
Line 1: Line 1:
Logs are generally located in /var/log directory, but can also be in specialized systems (e.g. Docker)


How to create a logrotate configuration (Linux)
Logrotate is a utility in Linux that manages log file rotation, archiving, and deletion automatically to prevent logs from consuming all disk space. The configuration is usually placed in /etc/logrotate.conf for global settings and in /etc/logrotate.d/ for application-specific log policies.​
To configure logrotate for a specific service, create a file in /etc/logrotate.d/, for example /etc/logrotate.d/nginx, and add a block describing how the log files should be rotated:
/var/log/nginx/*.log {
    daily
    rotate 7
    compress
    missingok
    notifempty
    create 640 root adm
    postrotate
        systemctl reload nginx > /dev/null
    endscript
}
How the rotation works:
When logrotate runs (automatically via cron or manually), it checks each log file per the configuration, archives old logs, creates new ones, and triggers the specified post-rotation actions.
For reference, see the full documentation:
https://wiki.archlinux.org/title/Logrotate
== Log rotation ==
=== Logrotate (Linux) ===
=== Newsyslog ===
== References ==
*

Revision as of 12:31, 22 November 2025

Logs are generally located in /var/log directory, but can also be in specialized systems (e.g. Docker)

How to create a logrotate configuration (Linux) Logrotate is a utility in Linux that manages log file rotation, archiving, and deletion automatically to prevent logs from consuming all disk space. The configuration is usually placed in /etc/logrotate.conf for global settings and in /etc/logrotate.d/ for application-specific log policies.​

To configure logrotate for a specific service, create a file in /etc/logrotate.d/, for example /etc/logrotate.d/nginx, and add a block describing how the log files should be rotated:

/var/log/nginx/*.log {

   daily
   rotate 7
   compress
   missingok
   notifempty
   create 640 root adm
   postrotate
       systemctl reload nginx > /dev/null
   endscript

}

How the rotation works: When logrotate runs (automatically via cron or manually), it checks each log file per the configuration, archives old logs, creates new ones, and triggers the specified post-rotation actions.

For reference, see the full documentation:

https://wiki.archlinux.org/title/Logrotate

Log rotation

Logrotate (Linux)

Newsyslog

References