<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>http://wiki.diouxx.be/index.php?action=history&amp;feed=atom&amp;title=Syslog-ng</id>
		<title>Syslog-ng - Historique des versions</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.diouxx.be/index.php?action=history&amp;feed=atom&amp;title=Syslog-ng"/>
		<link rel="alternate" type="text/html" href="http://wiki.diouxx.be/index.php?title=Syslog-ng&amp;action=history"/>
		<updated>2026-04-16T15:58:22Z</updated>
		<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
		<generator>MediaWiki 1.30.2</generator>

	<entry>
		<id>http://wiki.diouxx.be/index.php?title=Syslog-ng&amp;diff=43&amp;oldid=prev</id>
		<title>Ddevleeschauwer : Page créée avec « {{ Introduction | Cette page va vous permettre de mettre en place un système de log avec Syslog-ng }}  == Installation Syslog-ng ==  Que ça soit sur votre machine &quot;serve... »</title>
		<link rel="alternate" type="text/html" href="http://wiki.diouxx.be/index.php?title=Syslog-ng&amp;diff=43&amp;oldid=prev"/>
				<updated>2013-04-08T13:08:47Z</updated>
		
		<summary type="html">&lt;p&gt;Page créée avec « {{ Introduction | Cette page va vous permettre de mettre en place un système de log avec Syslog-ng }}  == Installation Syslog-ng ==  Que ça soit sur votre machine &amp;quot;serve... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{ Introduction | Cette page va vous permettre de mettre en place un système de log avec Syslog-ng }}&lt;br /&gt;
&lt;br /&gt;
== Installation Syslog-ng ==&lt;br /&gt;
&lt;br /&gt;
Que ça soit sur votre machine &amp;quot;server&amp;quot; qui va récolter les logs de plusieurs hosts ou sur la machine qui va envoyer ses logs sur un hôte distant, le paquet à installer est identiquement le même&lt;br /&gt;
&lt;br /&gt;
{{ Console root | apt-get install syslog-ng }}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Machine serveur ===&lt;br /&gt;
Pour configurer votre serveur afin qu'il puisse stocker les logs qu'on lui envoie, il vous faut éditer le fichier {{ File | /etc/syslog-ng/syslog-ng.conf }} :&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
options {&lt;br /&gt;
	# disable the chained hostname format in logs&lt;br /&gt;
        # (default is enabled)&lt;br /&gt;
        chain_hostnames(0);&lt;br /&gt;
&lt;br /&gt;
        # the time to wait before a died connection is re-established&lt;br /&gt;
        # (default is 60)&lt;br /&gt;
        time_reopen(10);&lt;br /&gt;
&lt;br /&gt;
        # the time to wait before an idle destination file is closed&lt;br /&gt;
        # (default is 60)&lt;br /&gt;
        time_reap(360);&lt;br /&gt;
&lt;br /&gt;
        # the number of lines buffered before written to file&lt;br /&gt;
        # you might want to increase this if your disk isn't catching with&lt;br /&gt;
        # all the log messages you get or if you want less disk activity&lt;br /&gt;
        # (say on a laptop)&lt;br /&gt;
        # (default is 0)&lt;br /&gt;
        #sync(0);&lt;br /&gt;
&lt;br /&gt;
        # the number of lines fitting in the output queue&lt;br /&gt;
        log_fifo_size(2048);&lt;br /&gt;
&lt;br /&gt;
        # enable or disable directory creation for destination files&lt;br /&gt;
        create_dirs(yes);&lt;br /&gt;
&lt;br /&gt;
        # default owner, group, and permissions for log files&lt;br /&gt;
        # (defaults are 0, 0, 0600)&lt;br /&gt;
        owner(root);&lt;br /&gt;
        #group(adm);&lt;br /&gt;
        perm(0640);&lt;br /&gt;
&lt;br /&gt;
        # default owner, group, and permissions for created directories&lt;br /&gt;
        # (defaults are 0, 0, 0700)&lt;br /&gt;
        dir_owner(root);&lt;br /&gt;
        #dir_group(root);&lt;br /&gt;
        dir_perm(0755);&lt;br /&gt;
&lt;br /&gt;
        # enable or disable DNS usage&lt;br /&gt;
        # syslog-ng blocks on DNS queries, so enabling DNS may lead to&lt;br /&gt;
        # a Denial of Service attack&lt;br /&gt;
        # (default is yes)&lt;br /&gt;
        use_dns(no);&lt;br /&gt;
&lt;br /&gt;
        # maximum length of message in bytes&lt;br /&gt;
        # this is only limited by the program listening on the /dev/log Unix&lt;br /&gt;
        # socket, glibc can handle arbitrary length log messages, but -- for&lt;br /&gt;
        # example -- syslogd accepts only 1024 bytes&lt;br /&gt;
        # (default is 2048)&lt;br /&gt;
        #log_msg_size(2048);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
########################&lt;br /&gt;
# Sources&lt;br /&gt;
########################&lt;br /&gt;
# all known message sources&lt;br /&gt;
source local {&lt;br /&gt;
        # message generated by Syslog-NG&lt;br /&gt;
        #internal();&lt;br /&gt;
        # standard Linux log source (this is the default place for the syslog()&lt;br /&gt;
        # function to send logs to)&lt;br /&gt;
        unix-stream(&amp;quot;/dev/log&amp;quot; max-connections(40));&lt;br /&gt;
        # messages from the kernel&lt;br /&gt;
        #file(&amp;quot;/proc/kmsg&amp;quot; log_prefix(&amp;quot;kernel: &amp;quot;));&lt;br /&gt;
        # use the following line if you want to receive remote UDP logging messages&lt;br /&gt;
        # (this is equivalent to the &amp;quot;-r&amp;quot; syslogd flag)&lt;br /&gt;
        # udp();&lt;br /&gt;
        tcp(ip(0.0.0.0));&lt;br /&gt;
        udp(ip(0.0.0.0));&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
########################&lt;br /&gt;
# Destinations         #&lt;br /&gt;
########################&lt;br /&gt;
#destination dst-all-messages {&lt;br /&gt;
#	file(&amp;quot;/var/log/archive/$R_YEAR-$R_MONTH-$R_DAY/messages&amp;quot;&lt;br /&gt;
#	template(&amp;quot;$HOUR:$MIN:$SEC $HOST &amp;lt;$FACILITY.$PRIORITY&amp;gt; $MSG\n&amp;quot;)&lt;br /&gt;
#	template_escape(no)&lt;br /&gt;
#	);&lt;br /&gt;
#};&lt;br /&gt;
&lt;br /&gt;
destination all-messages {&lt;br /&gt;
	file(&amp;quot;/var/log/syslog-ng/$HOST/messages.log&amp;quot;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
destination apache {&lt;br /&gt;
	file(&amp;quot;/var/log/syslog-ng/$HOST/apache.log&amp;quot;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
########################&lt;br /&gt;
# Filters&lt;br /&gt;
########################&lt;br /&gt;
# Here's come the filter options. With this rules, we can set which &lt;br /&gt;
# message go where.&lt;br /&gt;
&lt;br /&gt;
filter apache { program(&amp;quot;apache2&amp;quot;); };&lt;br /&gt;
&lt;br /&gt;
########################&lt;br /&gt;
# Log paths&lt;br /&gt;
########################&lt;br /&gt;
# Pour le auth.log du pare-feu&lt;br /&gt;
#log {&lt;br /&gt;
#        source(local);&lt;br /&gt;
#        destination(dst-all-messages);&lt;br /&gt;
#};&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
	source(local);&lt;br /&gt;
	destination(all-messages);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
	source(local);&lt;br /&gt;
	filter(apache);&lt;br /&gt;
	destination(apache);&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Machine Cliente ===&lt;br /&gt;
&lt;br /&gt;
Pour qu'une machine envoie ses logs sur un host distant, le fichier de configuration est toujours {{ File | /etc/syslog-ng/syslog-ng.conf }} :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
######&lt;br /&gt;
# options&lt;br /&gt;
&lt;br /&gt;
options {&lt;br /&gt;
        # disable the chained hostname format in logs&lt;br /&gt;
        # (default is enabled)&lt;br /&gt;
        chain_hostnames(0);&lt;br /&gt;
&lt;br /&gt;
        # the time to wait before a died connection is re-established&lt;br /&gt;
        # (default is 60)&lt;br /&gt;
        time_reopen(10);&lt;br /&gt;
&lt;br /&gt;
        # the time to wait before an idle destination file is closed&lt;br /&gt;
        # (default is 60)&lt;br /&gt;
        time_reap(360);&lt;br /&gt;
&lt;br /&gt;
        # the number of lines buffered before written to file&lt;br /&gt;
        # you might want to increase this if your disk isn't catching with&lt;br /&gt;
        # all the log messages you get or if you want less disk activity&lt;br /&gt;
        # (say on a laptop)&lt;br /&gt;
        # (default is 0)&lt;br /&gt;
        #sync(0);&lt;br /&gt;
&lt;br /&gt;
        # the number of lines fitting in the output queue&lt;br /&gt;
        log_fifo_size(2048);&lt;br /&gt;
&lt;br /&gt;
        # enable or disable directory creation for destination files&lt;br /&gt;
        create_dirs(yes);&lt;br /&gt;
&lt;br /&gt;
        # default owner, group, and permissions for log files&lt;br /&gt;
        # (defaults are 0, 0, 0600)&lt;br /&gt;
        owner(root);&lt;br /&gt;
        #group(adm);&lt;br /&gt;
        perm(0640);&lt;br /&gt;
&lt;br /&gt;
        # default owner, group, and permissions for created directories&lt;br /&gt;
        # (defaults are 0, 0, 0700)&lt;br /&gt;
        dir_owner(root);&lt;br /&gt;
        #dir_group(root);&lt;br /&gt;
        dir_perm(0755);&lt;br /&gt;
&lt;br /&gt;
        # enable or disable DNS usage&lt;br /&gt;
        # syslog-ng blocks on DNS queries, so enabling DNS may lead to&lt;br /&gt;
        # a Denial of Service attack&lt;br /&gt;
        # (default is yes)&lt;br /&gt;
        use_dns(no);&lt;br /&gt;
&lt;br /&gt;
        # maximum length of message in bytes&lt;br /&gt;
        # this is only limited by the program listening on the /dev/log Unix&lt;br /&gt;
        # socket, glibc can handle arbitrary length log messages, but -- for&lt;br /&gt;
        # example -- syslogd accepts only 1024 bytes&lt;br /&gt;
        # (default is 2048)&lt;br /&gt;
        #log_msg_size(2048);&lt;br /&gt;
&lt;br /&gt;
	#Disable statistic log messages.&lt;br /&gt;
	stats_freq(0);&lt;br /&gt;
&lt;br /&gt;
	# Some program send log messages through a private implementation.&lt;br /&gt;
	# and sometimes that implementation is bad. If this happen syslog-ng&lt;br /&gt;
	# may recognise the program name as hostname. Whit this option&lt;br /&gt;
	# we tell the syslog-ng that if a hostname match this regexp than that&lt;br /&gt;
	# is not a real hostname.&lt;br /&gt;
	bad_hostname(&amp;quot;^gconfd$&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	flush_lines (0);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
############################&lt;br /&gt;
# Sources&lt;br /&gt;
############################&lt;br /&gt;
# all known message sources&lt;br /&gt;
source s_all {&lt;br /&gt;
        # message generated by Syslog-NG&lt;br /&gt;
        #internal();&lt;br /&gt;
        # standard Linux log source (this is the default place for the syslog()&lt;br /&gt;
        # function to send logs to)&lt;br /&gt;
        unix-stream(&amp;quot;/dev/log&amp;quot;);&lt;br /&gt;
        # messages from the kernel&lt;br /&gt;
        #file(&amp;quot;/proc/kmsg&amp;quot; log_prefix(&amp;quot;kernel: &amp;quot;));&lt;br /&gt;
        # use the following line if you want to receive remote UDP logging messages&lt;br /&gt;
        # (this is equivalent to the &amp;quot;-r&amp;quot; syslogd flag)&lt;br /&gt;
        # udp();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
source apache {&lt;br /&gt;
	file(&amp;quot;/var/log/apache2/access.log&amp;quot; follow_freq(1) flags(no-parse));&lt;br /&gt;
	file(&amp;quot;/var/log/apache2/error.log&amp;quot; follow_freq(1) flags(no-parse));&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###########################&lt;br /&gt;
# Destinations&lt;br /&gt;
###########################&lt;br /&gt;
#Serveur distant&lt;br /&gt;
destination srv_dist {&lt;br /&gt;
	udp (&amp;quot;192.168.100.20&amp;quot; port(514));&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#Local&lt;br /&gt;
destination local_messages {&lt;br /&gt;
	file(&amp;quot;/var/log/syslog-ng/messages&amp;quot;);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################&lt;br /&gt;
# Filters&lt;br /&gt;
################################&lt;br /&gt;
# all messages from the auth and authpriv facilities&lt;br /&gt;
filter f_auth { facility(auth, authpriv); };&lt;br /&gt;
&lt;br /&gt;
# all messages except from the auth and authpriv facilities&lt;br /&gt;
filter f_syslog { not facility(auth, authpriv); };&lt;br /&gt;
&lt;br /&gt;
# respectively: messages from the cron, daemon, kern, lpr, mail, news, user,&lt;br /&gt;
# and uucp facilities&lt;br /&gt;
filter f_cron { facility(cron); };&lt;br /&gt;
filter f_daemon { facility(daemon); };&lt;br /&gt;
filter f_kern { facility(kern); };&lt;br /&gt;
filter f_lpr { facility(lpr); };&lt;br /&gt;
filter f_mail { facility(mail); };&lt;br /&gt;
filter f_news { facility(news); };&lt;br /&gt;
filter f_user { facility(user); };&lt;br /&gt;
filter f_uucp { facility(uucp); };&lt;br /&gt;
&lt;br /&gt;
# some filters to select messages of priority greater or equal to info, warn,&lt;br /&gt;
# and err&lt;br /&gt;
# (equivalents of syslogd's *.info, *.warn, and *.err)&lt;br /&gt;
filter f_at_least_info { level(info..emerg); };&lt;br /&gt;
filter f_at_least_notice { level(notice..emerg); };&lt;br /&gt;
filter f_at_least_warn { level(warn..emerg); };&lt;br /&gt;
filter f_at_least_err { level(err..emerg); };&lt;br /&gt;
filter f_at_least_crit { level(crit..emerg); };&lt;br /&gt;
&lt;br /&gt;
# all messages of priority debug not coming from the auth, authpriv, news, and&lt;br /&gt;
# mail facilities&lt;br /&gt;
filter f_debug { level(debug) and not facility(auth, authpriv, news, mail); };&lt;br /&gt;
&lt;br /&gt;
# all messages of info, notice, or warn priority not coming form the auth,&lt;br /&gt;
# authpriv, cron, daemon, mail, and news facilities&lt;br /&gt;
filter f_messages {&lt;br /&gt;
        level(info,notice,warn)&lt;br /&gt;
            and not facility(auth,authpriv,cron,daemon,mail,news);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
# messages with priority emerg&lt;br /&gt;
filter f_emerg { level(emerg); };&lt;br /&gt;
&lt;br /&gt;
# complex filter for messages usually sent to the xconsole&lt;br /&gt;
filter f_xconsole {&lt;br /&gt;
    facility(daemon,mail)&lt;br /&gt;
        or level(debug,info,notice,warn)&lt;br /&gt;
        or (facility(news)&lt;br /&gt;
                and level(crit,err,notice));&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
###################################################&lt;br /&gt;
# Filtre &amp;quot;perso&amp;quot;&lt;br /&gt;
##################################################&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
######&lt;br /&gt;
# logs&lt;br /&gt;
# order matters if you use &amp;quot;flags(final);&amp;quot; to mark the end of processing in a&lt;br /&gt;
# &amp;quot;log&amp;quot; statement&lt;br /&gt;
&lt;br /&gt;
# these rules provide the same behavior as the commented original syslogd rules&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
        source(s_all);&lt;br /&gt;
	destination(srv_dist);&lt;br /&gt;
	filter(f_auth);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
	source(apache);&lt;br /&gt;
	destination(srv_dist);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
	source(s_all);&lt;br /&gt;
	destination(local_messages);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Astuces ===&lt;br /&gt;
&lt;br /&gt;
==== Filtre selon l'IP ====&lt;br /&gt;
&lt;br /&gt;
Il est possible de filter des logs sur l'adresse IP. Pour ce faire, le filtre ressemble à ceci :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter sogo { netmask(192.168.100.130/255.255.255.255); };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dans ce cas-ci, on filtre les logs arrivant de la machine ayant l'adresse IP : 192.168.100.130&lt;br /&gt;
&lt;br /&gt;
== Splunk ==&lt;br /&gt;
Voir la page [[Splunk]]&lt;br /&gt;
&lt;br /&gt;
== Logrotate ==&lt;br /&gt;
Pour configurer la rotation des logs, voir la page [[Logrotate]]&lt;br /&gt;
[[Catégorie:Système]]&lt;/div&gt;</summary>
		<author><name>Ddevleeschauwer</name></author>	</entry>

	</feed>