LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 871|回复: 0

[求助]sylog-ng 无法向mysql数据库写数据

[复制链接]
发表于 2011-3-23 13:13:15 | 显示全部楼层 |阅读模式
想用syslog-ng 和 php-syslog-ng做日志管理,syslog-ng已经基本配置好了,各种log文件也已经生产,mysql也安装好启动了,php也可以用,但syslog-ng就是不能向mysql数据库写数据,打开php-syslog-ng也说logs表是空的
syslog-ng.conf配置文件如下

  1. options {
  2. long_hostnames(off);
  3. log_msg_size(8192);
  4. flush_lines(1);
  5. log_fifo_size(20480);
  6. time_reopen(10);
  7. use_dns(yes);
  8. dns_cache(yes);
  9. use_fqdn(yes);
  10. keep_hostname(yes);
  11. chain_hostnames(no);
  12. perm(0644);
  13. stats_freq(43200);
  14. };
  15. source s_internal { internal();};
  16. destination d_syslognglog { file("/var/log/syslog-ng.log");};
  17. log { source(s_internal); destination(d_syslognglog);};

  18. ######
  19. # sources
  20. source s_local {
  21. unix-dgram("/dev/log");
  22. file("/proc/kmsg" program_override("kernel:"));
  23. };

  24. ######
  25. # destinations
  26. destination d_messages { file("/var/log/messages"); };


  27. log {
  28. source(s_local);
  29. destination(d_messages);
  30. };

  31. filter f_messages { level(info..emerg);};
  32. filter f_secure { facility(authpriv);};
  33. filter f_mail { facility(mail);};
  34. filter f_cron { facility(cron);};
  35. filter f_emerg { level(emerg);};
  36. filter f_spooler { level(crit..emerg) and facility(uucp,news);};
  37. filter f_local7 { facility(local7);};

  38. destination d_messages {file("/var/log/messages");};
  39. destination d_secure { file("/var/log/secure");};
  40. destination d_maillog { file("/var/log/maillog");};
  41. destination d_cron { file("/var/log/cron");};
  42. destination d_console { usertty("root");};
  43. destination d_spooler { file("/var/log/spooler");};
  44. destination d_bootlog { file("/var/log/boot.log");};

  45. log { source(s_local); filter(f_emerg); destination(d_console);};
  46. log { source(s_local); filter(f_secure); destination(d_secure); flags(final);};
  47. log { source(s_local); filter(f_mail); destination(d_maillog); flags(final);};
  48. log { source(s_local); filter(f_cron); destination(d_cron); flags(final);};
  49. log { source(s_local); filter(f_spooler); destination(d_spooler);};
  50. log { source(s_local); filter(f_local7);destination(d_bootlog);};
  51. log { source(s_local); filter(f_messages);destination(d_messages);};

  52. # Remote logging
  53. source s_remote {
  54. tcp(ip(0.0.0.0) port(514));
  55. udp(ip(0.0.0.0) port(514));
  56. };

  57. destination r_console {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/console" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};
  58. destination r_secure {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/secure" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};
  59. destination r_cron {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/cron" owner("root") group ("root") perm(0640) dir_perm(0750) create_dirs(yes));};
  60. destination r_spooler {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/spooler" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};
  61. destination r_bootlog {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/bootlog" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};
  62. destination r_messages {file("/var/log/syslog-ng/$YEAR$MONTH$DAY/$HOST/messages" owner("root") group("root") perm(0640) dir_perm(0750) create_dirs(yes));};

  63. log { source(s_remote); filter(f_emerg); destination(r_console);};
  64. log { source(s_remote); filter(f_secure); destination(r_secure); flags(final);};
  65. log { source(s_remote); filter(f_cron); destination(r_cron); flags(final);};
  66. log { source(s_remote); filter(f_spooler); destination(r_spooler);};
  67. log { source(s_remote); filter(f_local7); destination(r_bootlog);};
  68. log { source(s_remote); filter(f_messages); destination(r_messages);};

  69. destination d_mysql {
  70. program("/usr/bin/mysql -usyslogadmin -psyslogadmin syslog"
  71. 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")
  72. template-escape(yes));
  73. };
  74. log {
  75. source(s_remote);
  76. destination(d_mysql);
  77. };
复制代码


大家帮我看看配置文件有没有问题,如果配置文件没有问题,大概会是什么问?谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表