syslog接收客户端发送的日志

仅仅是这一个简单的功能,不想再重新再用java重新做。

直接用nginx+php往syslog中写,syslog往mysql中输出,使用log查看工具查看日志。

php中打开syslog输出:

1、编辑php.ini

取消下面一行的注释

error_log = syslog

2、重启nginx+php

3、写php测试一下:

<?php
        openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR);
        syslog(LOG_INFO, 'hello php');
?>

4、在/var/log/message中可以看到输出:

php[21641]:  hello php
php[21642]:  hello php
php[21643]:  hello php
发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /opt/wordpress/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048