2011年2月13日 星期日

Apache log傳送至syslog

[root@snort ]# vi /usr/local/sbin/apache2syslog_error
內容如下
#!/usr/bin/perl
use Sys::Syslog qw (:DEFAULT setlogsock);

setlogsock('unix');
# open our log socket
openlog('httpd', 'pid', 'local7');

# log all our input
while (<STDIN>) {
       syslog('ERR', $_);
}

# close the log socket
closelog;

[root@snort ]#vi /usr/local/sbin/apache2syslog
#!/usr/bin/perl
use Sys::Syslog qw (:DEFAULT setlogsock);
setlogsock('unix');
# open our log socket
openlog('httpd', 'pid', 'local7');

# log all our input
while (<STDIN>) {
       syslog('info', $_);
}

# close the log socket
closelog;


[root@snort ]# chown root:root /usr/local/sbin/apache2sys*
[root@snort ]# chmod 700 /usr/local/sbin/apache2sys*

編輯httpd.conf檔案[root@snort phplogcon]# vi /etc/httpd/conf/httpd.conf
ErrorLog  | /usr/local/sbin/apache2syslog_error
CustomLog | /usr/local/sbin/apache2syslog  combined
[root@snort phplogcon]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                             [  OK  ]


 

沒有留言:

張貼留言