|
|
| Zeile 48: |
Zeile 48: |
|
| |
|
| ==logrotate== | | ==logrotate== |
| ''logrotate'' rotiert und komprimiert Logdateien, damit diese nicht unkontrolliert anwachsen.
| | [[Logrotate]] |
| * Die Konfig-Dateien sind: ''/etc/logrotate.conf'' und ''/etc/logrotate.d''
| |
| * Nach Ablauf eines Intervalls verschiebt er die Datei, indem er die Dateiendung ''.1'' hinten anstellt, beim nächsten Intervall wird die zuvor verschobene Datei wieder umbenannt und diesmal auch noch komprimiert, sodass hinten ein ''.2.gz'' steht.
| |
| * Wie viele alte Logfiles und das Intervall kann man in der ''logrotate.conf'' ändern
| |
| | |
| So könnte eine ''logrotate.conf'' aussehen:
| |
| <syntaxhighlight lang="bash" highlight="1" line copy>
| |
| </syntaxhighlight>
| |
| # see "man logrotate" for details
| |
| # rotate log files weekly
| |
| weekly
| |
|
| |
| # keep 4 weeks worth of backlogs
| |
| rotate 4
| |
|
| |
| # create new (empty) log files after rotating old ones
| |
| create
| |
|
| |
| # uncomment this if you want your log files compressed
| |
| #compress
| |
|
| |
| # packages drop log rotation information into this directory
| |
| include /etc/logrotate.d
| |
|
| |
| # no packages own wtmp, or btmp -- we'll rotate them here
| |
| /var/log/wtmp {
| |
| missingok
| |
| monthly
| |
| create 0664 root utmp
| |
| rotate 1
| |
| }
| |
|
| |
| /var/log/btmp {
| |
| missingok
| |
| monthly
| |
| create 0660 root utmp
| |
| rotate 1
| |
| }
| |
| | |
| Dateien in logrotate.d sind nach dem gleichen Muster aufgebaut
| |
| <syntaxhighlight lang="bash" highlight="1" line copy>
| |
| </syntaxhighlight>
| |
| root@alex:/etc/logrotate.d# cat apt
| |
| /var/log/apt/term.log {
| |
| rotate 12
| |
| monthly
| |
| compress
| |
| missingok
| |
| notifempty
| |
| }
| |
|
| |
| /var/log/apt/history.log {
| |
| rotate 12
| |
| monthly
| |
| compress
| |
| missingok
| |
| notifempty
| |
| }
| |
| | |
| ''logrotate'' sollte am besten täglich ausgeführt werden. Hierfür eignet sich ''[[cron]]''.
| |
|
| |
|
| == systemd-journald == | | == systemd-journald == |
LPIC102/108.2 Systemprotokollierung
Beschreibung
- Wichtige Programme sind rsyslog und journald
- Die Konfig-Dateien von rsyslog sind in der /etc/rsyslog.conf
- Enthält Regeln für das Logging
- Im Verzeichnis /var/log stehen die ganzen Log-Dateien
- Mit less oder tail -f anzeigen
- logrotate verschiebt (rotiert) und komprimiert Logdateien
- *Die Konfig-Datei für logrotate ist die /etc/logrotate.conf
- Logdateien von anderen Dateien sind in der /etc/logrotate.d
- journald ist Teil des systemd und kann mit journalctl aufgerufen werden
- Die Konfig-Datei für journald ist in der /etc/systemd/journald.conf
- Mit logger kann man Ereignisse in syslog oder in journald schreiben
- Protokollierung von Ereignissen zur Fehlerbehebung
- Linux-Kernel
- Dienste
- Programme
- Wissensgebiete
| Orte |
Verzeichnisse, in denen Protokolle gespeichert werden
|
| Programme |
Protokolle auswerten
|
| Konfigurationsdateien |
Protokollierung steuern
|
- Programme und Dienste zur Protokollierung von Ereignissen
rsyslog
Rsyslog
Logdateien untersuchen
Logdateien untersuchen
logrotate
Logrotate
systemd-journald
Systemd/Journald
Selbst Ereignisse loggen
Logger