Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:base-system:log.essentials [2023/02/27 22:07] – Fix typo tart | docs:guide-user:base-system:log.essentials [2024/06/02 06:30] – [logread] stokito | ||
|---|---|---|---|
| Line 55: | Line 55: | ||
| ===== logd ===== | ===== logd ===== | ||
| - | '' | + | '' |
| + | It also listens for ''/ | ||
| + | It' | ||
| - | < | + | < |
| - | / | + | service |
| - | / | + | service |
| </ | </ | ||
| Line 70: | Line 72: | ||
| ==== logread ==== | ==== logread ==== | ||
| - | This is the default interface | + | This is the default interface |
| - | It is a local executable that will read the ring buffer records and display them chronologically. | + | |
| + | It is a local executable | ||
| + | |||
| + | To show all log messages that contains a specific text (like a daemon name) and follow (like in '' | ||
| + | <code bash> | ||
| + | logread -fe firewall | ||
| + | </ | ||
| + | |||
| + | Options: | ||
| + | < | ||
| + | -s < | ||
| + | -l < | ||
| + | -e < | ||
| + | -r < | ||
| + | -F < | ||
| + | -S < | ||
| + | -p < | ||
| + | -h < | ||
| + | -P < | ||
| + | -z < | ||
| + | -Z < | ||
| + | -f Follow log messages | ||
| + | -u Use UDP as the protocol | ||
| + | -t Add an extra timestamp | ||
| + | -0 Use \0 instead of \n as trailer when using TCP | ||
| + | </ | ||
| + | |||
| + | Please note that if you install the [[: | ||
| + | |||
| ==== Local file logging ==== | ==== Local file logging ==== | ||
| Line 107: | Line 138: | ||
| </ | </ | ||
| - | and then reload the rules using '' | + | and then reload the rules using '' |
| For the LAN-side station/ | For the LAN-side station/ | ||
| Line 136: | Line 167: | ||
| If you want to test the logging out, just run a command like | If you want to test the logging out, just run a command like | ||
| - | '' | + | < |
| and it should be written to the configured destination. | and it should be written to the configured destination. | ||
| Line 143: | Line 174: | ||
| * ''/ | * ''/ | ||
| * '' | * '' | ||
| - | * restart it using '' | + | * restart it using '' |
| + | |||
| + | ===== Logrotate ===== | ||
| + | To automatically manage large collections of daily, weekly, or monthly logs, you may want to use [[packages: | ||
| + | Here's an example that rotates a persistent log on a USB storage each night keeping it for 1 week. | ||
| + | |||
| + | <code bash> | ||
| + | # Install packages | ||
| + | opkg update | ||
| + | opkg install logrotate | ||
| + | |||
| + | # Configure logging | ||
| + | uci set system.@system[0].log_file="/ | ||
| + | uci set system.@system[0].log_remote=" | ||
| + | uci commit system | ||
| + | service system restart | ||
| + | |||
| + | # Configure logrotate | ||
| + | cat << " | ||
| + | include / | ||
| + | / | ||
| + | daily | ||
| + | rotate 1 | ||
| + | missingok | ||
| + | notifempty | ||
| + | postrotate | ||
| + | service log restart | ||
| + | sleep 1 | ||
| + | logger -p warn -s "Log rotation complete" | ||
| + | endscript | ||
| + | } | ||
| + | EOF | ||
| + | |||
| + | # Configure cron | ||
| + | cat << " | ||
| + | 58 23 * * * logrotate / | ||
| + | EOF | ||
| + | service cron restart | ||
| + | |||
| + | # Debugging | ||
| + | logrotate --verbose --debug / | ||
| + | </ | ||
| ===== Alternative implementations ===== | ===== Alternative implementations ===== | ||
| Line 160: | Line 232: | ||
| </ | </ | ||
| + | If you add to the rsyslog receiver' | ||
| + | |||
| + | < | ||
| + | $template DynamicFile,"/ | ||
| + | *.* -? | ||
| + | </ | ||
| + | you get the messages separated from every sender in a own folder. | ||
| ===== rsyslog and Logz.io ===== | ===== rsyslog and Logz.io ===== | ||
| You can support logging direct to a cloud ELK provider like Logz.io by adding a few lines to your '' | You can support logging direct to a cloud ELK provider like Logz.io by adding a few lines to your '' | ||