On Fri, 2008-09-05 at 15:12 +0200, Stallmann, Andreas wrote:
Hi there,
I'm trying to let syslog-ng log to a mysql database, which is somehow not working (anymore).
All my network traffic is supposed to be written into a separate logfile as well as into a mysql database. I followed the HowTo on http://gentoo-wiki.com/HOWTO_setup_PHP-Syslog-NG#Syslog-ng_INIT_Script, and altered the configuration to fit my needs. Here it comes:
############################################ source net { udp(ip("0.0.0.0") port(514)); };
destination d_mysql { program("/usr/bin/mysql --reconnect -f -T --user=syslogfeeder --password=PASSWORD syslog >> /var/log/db_log.log 2>&1" template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC','$PROGRAM', '$MSG' );\n") template-escape(yes)); };
Apart from the specific problem one note I have is that syslog-ng OSE 2.1 can do inserts on its own, without the help of the mysql binary. -- Bazsi