PHP SeasLog

编译安装

wget https://github.com/Neeke/SeasLog/archive/master.zip

unzip master.zip

cp -r SeasLog-master /usr/local/SeasLog

cd /usr/local/SeasLog/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install 安装成功之后会有seaslog.so的路径返回

php.ini 添加extension=seaslog.so

重启nginx

phpinfo() 或者 php -m 查看是否开启

 

补充windows安装

下载对应的dll版本,解压文件,找到php_seaslog.dll 复制到php的dll目录

http://pecl.php.net/package/SeasLog/1.8.4/windows

重启NPM

-end-

 

查看是否成功,查看具体配置(配置说明 https://www.jianshu.com/p/b5c01eb49df0 )

部分配置说明:

php.ini  添加配置

[seaslog]
extension = "seaslog.so"
seaslog.default_basepath = /data/projlogs/sesalog
seaslog.default_logger = bookslog
seaslog.disting_type = 0
seaslog.disting_by_hour = 0
seaslog.use_buffer = 1
seaslog.buffer_size = 500
;seaslog.level = 0                                       ;记录日志级别 默认0(所有日志)
seaslog.trace_error = 1
seaslog.trace_exception = 0
seaslog.default_datetime_format = "Y:m:d H:i:s"
seaslog.appender = 1

官方地址:

https://github.com/Neeke/SeasLog/blob/master/README_zh.md

写入到文件格式如下:

模板默认为:seaslog.default_template = “%T | %L | %P | %Q | %t | %M”
意味着,默认的格式为{dateTime} | {level} | {pid} | {uniqid} | {timeStamp} | {logInfo}

2019:05:27 17:20:37 | INFO | 20225 | 5cebabe5bcce2 | 1558948837.777 | this is kiwi test info_aaaaa
2019:05:27 17:20:37 | INFO | 20225 | 5cebabe5bcce2 | 1558948837.777 | this is kiwi test info

更多功能,需要自测~!