rsyslog und andere logfiles
Rsyslog und andere logfiles
Hier eine kleine Anleitung wie man Rsyslog dazu nutzen kann auch andere logfiles zu versenden ohne den entsprechenden Dienst anzupassen.
Um den Rsyslog Server zu erstellen hab ich hier schon eine Anleitung geschrieben.
In diesem Beispiel verwende ich die Logfiles vom Apache, die ich auf dem Rsyslog Server unter dem Client Hostnamen/apache speichern will.
Anpassen der Rsyslog Config auf dem Rsyslog Server.
Als erstes erweitern wir auf dem Rsyslog Server die config damit er die neuen Messages nicht einfach ins Syslog schreibt.
# Seperate Log Regel fuer Apache Access und Errors logs $template APACHE_ACCESS, "/var/log/rsyslog/%HOSTNAME%/apache/access.log" if $programname == 'apache_access' then ?APACHE_ACCESS & ~ $template APACHE_ERROR, "/var/log/rsyslog/%HOSTNAME%/apache/error.log" if $programname == 'apache_error' then ?APACHE_ERROR & ~
Speichern und den Rsyslog neu starten.
Auf dem Apache Server erstellen wir zwei Konfigurationsfiles.
Einmal fürs access.log
#Only needs to be loaded once, like most rsyslog modules $ModLoad imfile #path to the file which you want to monitor $InputFileName /var/log/apache2/access.log #The tag apache can be changed to whatever you'd like $InputFileTag apache_access: #the name of file within rsyslogs working directory $InputFileStateFile stat-apache-access #By default this is set to 'notice' $InputFileSeverity info #This is necessary for file monitoring (no parameters) $InputRunFileMonitor #Set to how often the file should be polled. (default = 10s) $InputFilePollInterval 10
Und nochmal fürs error.log
#Only needs to be loaded once, like most rsyslog modules $ModLoad imfile #path to the file which you want to monitor $InputFileName /var/log/apache2/error.log #The tag apache can be changed to whatever you'd like $InputFileTag apache_error: #the name of file within rsyslogs working directory $InputFileStateFile stat-apache-error #By default this is set to 'notice' $InputFileSeverity info #This is necessary for file monitoring (no parameters) $InputRunFileMonitor #Set to how often the file should be polled. (default = 10s) $InputFilePollInterval 10
Auch hier den Rsyslog Dienst neu starten
Nun sollten die Apache Logfiles auf den Rsyslog Server erscheinen.
Dies kann man für jede gewünschte logfile anpassen.
Hallo
komisch bei mir werden die Apache logfiles nicht übertragen
habe das nach deinen Vorgaben eingebaut
haste eine Idee
die anderen werden 1:1 sauber übertragen
Also ich hab das gerade bei mir nochmal für einen anderen Server eingerichtet. Und da Funktioniert es auf Anhieb.
Alle anderen Logs werden übertragen? also auth, cron, …… , syslog
Nur die Extra Einstellung für die Apache werden nicht vom Rsyslog auf den entfernten Rsyslog Server übertragen ?