php 之 日志系统seaslog安装


特点:

  1、高性能(使用C语言编写的)。

  2、无需配置。

  3、功能完善、使用简单。


安装:

  打开php的扩展官网:https://pecl.php.net/

  然后搜索Seaslog,

  选择最新的版本下载:

wget https://pecl.php.net/get/SeasLog-1.8.4.tgz

解压:

tar zxvf SeasLog-1.8.4.tgz 

然后进入SeasLog目录

cd SeasLog-1.8.4/

然后执行phpize:

关于什么是phpize,参考博客:https://blog.csdn.net/qq_16399991/article/details/70577740。

phpize

如果显示命令未找到:

就先安装php-dev:

sudo apt-get install php5-dev

下一步,执行configure:

./configure 

如果报错,显示命令未找到php-config,就需要添加自己的php路径:

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

下一步:

sudo make && make install

如果提示目录没有权限,就修改指定目录的权限。

安装结果:

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:

进入目录查看:

cd /usr/lib/php5/20121212/

可以看到:seaslog.so。

然后修改php.ini文件。

如果不知道php.ini文件在哪,可以通过phpinfo查看。

Nginx:

Loaded Configuration File /etc/php5/fpm/php.ini

apache:

Loaded Configuration File /etc/php5/apache2

打开php.ini,增加一行:

extension = "seaslog.so"

然后重启nginx服务或apache服务,再查看phpinfo,就可以看到安装成功。

打开Seaslog的github:https://github.com/SeasX/SeasLog

找到Seaslog.ini,复制内容到php.ini中。

;configuration for php SeasLog module
extension = seaslog.so

;Default Log Base Path
seaslog.default_basepath = "/var/log/www"

;Default Logger Path
seaslog.default_logger = "default"

;The DateTime Style.  Default "Y-m-d H:i:s"
seaslog.default_datetime_format = "Y-m-d H:i:s"

;Default Log template. 
;Default "%T | %L | %P | %Q | %t | %M"
seaslog.default_template = "%T | %L | %P | %Q | %t | %M"

;Switch use the logger with folder. 
;1-Y(Default) 0-N
seaslog.disting_folder = 1

;Switch use the logger with type.
;1-Y 0-N(Default)
seaslog.disting_type = 0

;Switch use the logger with hour.
;1-Y 0-N(Default)
seaslog.disting_by_hour = 0

;Switch use the log buffer with memory.
;1-Y 0-N(Default)
seaslog.use_buffer = 0

;The buffer size
seaslog.buffer_size = 100

;disable buffer in cli
;1-Y 0-N(Default)
seaslog.buffer_disabled_in_cli = 0

;Record logger level. 
;0-EMERGENCY 1-ALERT 2-CRITICAL 3-ERROR 4-WARNING 5-NOTICE 6-INFO 7-DEBUG 8-ALL
;Default 8 (All of them).
;
;   Tips: The configuration item has changed since the 1.7.0 version.
;   Before the 1.7.0 version, the smaller the value, the more logs are taken according to the level: 
;   0-all 1-debug 2-info 3-notice 4-warning 5-error 6-critical 7-alert 8-emergency
;   Before the 1.7.0 version, Default 0 (All of them).
seaslog.level = 8

;Log function recall depth
;Will affected variable `LineNo` in `%F`
;Default 0
seaslog.recall_depth = 0

;Automatic Record notice with default logger
;1-Y 0-N(Default)
seaslog.trace_notice = 0

;Automatic Record warning with default logger
;1-Y 0-N(Default)
seaslog.trace_warning = 0

;Automatic Record final error with default logger. 
;1-Y(Default) 0-N
seaslog.trace_error = 1

;Automatic Record exception with default logger. 
;1-Y 0-N(Default)
seaslog.trace_exception = 0

;Switch the Record Log Data Store.     
;1File 2TCP 3UDP (Switch default 1)
seaslog.appender = 1

;Record Log Retry Count 
;Default 0 (Do Not Retry)
seaslog.appender_retry = 0

;If you use  Record TCP or UDP, configure this remote ip.
;Default "127.0.0.1"
seaslog.remote_host = "127.0.0.1"

;If you use Record TCP or UDP, configure this remote port.
;Default 514
seaslog.remote_port = 514

;If you use Record TCP or UDP, configure this remote timeout.
;Default 1 second
seaslog.remote_timeout = 1

;Trim the \n and \r in log message.
;1-On 0-Off(Default)
seaslog.trim_wrap = 0

;Switch throw SeasLog exception.
;1-On(Default) 0-Off
seaslog.throw_exception = 1

;Switch ignore SeasLog warning.
;1-On(Default) 0-Off
seaslog.ignore_warning = 1