edfwe 发表于 2015-5-5 08:29:22

使用Logstash收集PHP相关日志

这里收集三种日志

PHP的错误日志,PHP-FPM的错误日志和慢查询日志

在php.ini中设置
error_log = /data/app_data/php/logs/php_errors.log

在php-fpm.conf中设置
error_log = /data/app_data/php/logs/php-fpm_error.log
slowlog = /data/app_data/php/logs/php-fpm_slow.log

PHP错误日志如下:


1
2
3
4
5
6
7
8
9
PHP Warning:PHP Startup: Unable to load dynamic library '/data/app_platform/php/lib/php/exte
nsions/no-debug-non-zts-20100525/redis.so' - /data/app_platform/php/lib/php/extensions/no-debug-non-zts-20100525/redis.so
: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:PHP Startup: Unable to load dynamic library '/data/app_platform/php/lib/php/exte
nsions/no-debug-non-zts-20100525/apc.so' - /data/app_platform/php/lib/php/extensions/no-debug-non-zts-20100525/apc.so: ca
nnot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:PHP Startup: Unable to load dynamic library '/data/app_platform/php/lib/php/exte
nsions/no-debug-non-zts-20100525/mongo.so' - /data/app_platform/php/lib/php/extensions/no-debug-non-zts-20100525/mongo.so
: cannot open shared object file: No such file or directory in Unknown on line 0





PHP-FPM错误日志如下:


1
2
3
4
5
6
7
8
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)
ERROR: unable to read what child say: Bad file descriptor (9)





PHP-FPM的慢查询日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pid 12873
script_filename = /data//index.php
curl_exec() /data//Account.php:221
call() /data/gintama_app/jidong/game_code/app/controllers/Game.php:31
load() unknown:0
call_user_func_array() /data/library/BaseCtrl.php:20
handoutAction() unknown:0
run() /data//index.php:30

pid 12881
script_filename = /data/index.php
curl_exec() /data//Account.php:221
call() /data/Game.php:31
load() unknown:0
call_user_func_array() /data/library/BaseCtrl.php:20
handoutAction() unknown:0
run() /data/index.php:30







页: [1]
查看完整版本: 使用Logstash收集PHP相关日志