zoukankan      html  css  js  c++  java
  • php 日志处理工具 SeasLog 的使用

    首先附上seaslog github地址:

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

    php官方文档地址:

      https://www.php.net/manual/zh/class.seaslog.php

    SeasLog是一个C语言编写的PHP扩展,提供一组规范标准的功能函数,在PHP项目中方便、规范、高效地写日志,以及快速地读取和查询日志。

    一.什么是日志系统

    1. 记录系统运行时的信息

    2. 系统日志、应用程序日志、安全日志

    3. 日志功能不应该影响到用户的正常使用

    二.为什么需要日志功能

    1. 了解系统运行情况

    2. 记录用户操作信息

    3. 收集数据

    三.为什么选择SeasLog

    1. 高性能(C语言做的 先将日志写入内存达到一定量再写入文件比频繁写入文件好)。

    2. 无需配置

    3. 功能完善、

    4. 使用简单

    四.安装SeasLog

    pecl install seaslog

    五.配置SeasLog

    通过修改php.ini,修改seaslog配置

    [seaslog]
    seaslog.default_basepath = /home/www/log/               ;默认log根目录
    seaslog.default_logger = seaslog                        ;默认logger目录
    seaslog.disting_type = 0                                ;是否以type分文件 1是 0>否(默认)
    seaslog.disting_by_hour = 0                             ;是否每小时划分一个文件 1是 0否(默认)
    seaslog.use_buffer = 1                                  ;是否启用buffer 1是 0否(默认)
    seaslog.buffer_size = 500                               ;buffer中缓冲数量 默认0(不使用buffer_size)
    seaslog.level = 0                                       ;记录日志级别 默认0(所有
    日志)
    seaslog.trace_error = 1                                 ;自动记录错误 默认1(开启
    )
    seaslog.trace_exception = 0                             ;自动记录异常信息 默认0(关闭)
    seaslog.default_datetime_format = "Y:m:d H:i:s"         ;日期格式配置 默认"Y:m:d H:i:s"
    seaslog.appender = 1                                    ;日志存储介质 1File 2TCP 3UDP (默认为1)
    seaslog.remote_host = 127.0.0.1                         ;接收ip 默认127.0.0.1 (>当使用TCP或UDP时必填)
    seaslog.remote_port = 514                               ;接收端口 默认514 (当使>用TCP或UDP时必填)
    seaslog.trim_wrap = 0                                   ;过滤日志中的回车和换行>符 (默认为0)

    六.使用

    SeasLog {
    /* 方法 */
    public static alert ( string $message [, array $content [, string $logger ]] ) : bool
    public static analyzerCount ( string $level [, string $log_path [, string $key_word ]] ) : mixed
    public static analyzerDetail ( string $level [, string $log_path [, string $key_word [, int $start [, int $limit [, int $order ]]]]] ) : mixed
    public static closeLoggerStream ( int $model , string $logger ) : bool
    public static critical ( string $message [, array $content [, string $logger ]] ) : bool
    public static debug ( string $message [, array $content [, string $logger ]] ) : bool
    public __destruct ( void )
    public static emergency ( string $message [, array $content [, string $logger ]] ) : bool
    public static error ( string $message [, array $content [, string $logger ]] ) : bool
    public static flushBuffer ( void ) : bool
    public static Seaslog::getBasePath ( void ) : string
    public static getBuffer ( void ) : array
    public static getBufferEnabled ( void ) : bool
    public static getDatetimeFormat ( void ) : string
    public static getLastLogger ( void ) : string
    public static getRequestID ( void ) : string
    public static getRequestVariable ( int $key ) : bool
    public static info ( string $message [, array $content [, string $logger ]] ) : bool
    public static log ( string $level [, string $message [, array $content [, string $logger ]]] ) : bool
    public static notice ( string $message [, array $content [, string $logger ]] ) : bool
    public static setBasePath ( string $base_path ) : bool
    public static setDatetimeFormat ( string $format ) : bool
    public static setLogger ( string $logger ) : bool
    public static setRequestID ( string $request_id ) : bool
    public static setRequestVariable ( int $key , string $value ) : bool
    public static warning ( string $message [, array $content [, string $logger ]] ) : bool
    }

  • 相关阅读:
    HDU 1124 Factorial(简单数论)
    29.QT主窗口加widget
    28.开始画面和异形窗口
    27.Qt时钟
    26.QT颜色与布局
    25.QT进度条
    146.正则表达式
    24.qint64转QString 以及获取文件属性
    23.QFile遍历
    22.监视文件
  • 原文地址:https://www.cnblogs.com/starfish29/p/11502504.html
Copyright © 2011-2022 走看看