Operations grimoire/Logs: Difference between revisions
No edit summary Tag: Manual revert |
|||
| Line 31: | Line 31: | ||
=== Newsyslog === | === Newsyslog === | ||
To create a configuration for newsyslog under FreeBSD, you need to add or modify a line in the main file /etc/newsyslog.confor in an auxiliary configuration file, often specific to a service. | |||
/var/log/www/*/*.log root:web 640 90 * @T00 JC /var/run/nginx.pid 30 | |||
If you're manipulating patterns with wildcards (like *), don't forget the option G. Otherwise, the system might create a literal file named ` *` or not process the files as expected. | |||
For a field-by-field explanation, see the man page: | |||
https://man.freebsd.org/cgi/man.cgi?newsyslog.conf(5) | |||
== References == | == References == | ||
* | * | ||
Revision as of 12:35, 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
To create a configuration for newsyslog under FreeBSD, you need to add or modify a line in the main file /etc/newsyslog.confor in an auxiliary configuration file, often specific to a service.
/var/log/www/*/*.log root:web 640 90 * @T00 JC /var/run/nginx.pid 30
If you're manipulating patterns with wildcards (like *), don't forget the option G. Otherwise, the system might create a literal file named ` *` or not process the files as expected.
For a field-by-field explanation, see the man page:
https://man.freebsd.org/cgi/man.cgi?newsyslog.conf(5)
