SeasLog-1.5.6 released, memory I/O optimized version of PHP log extension

Source: Internet
Author: User
SeasLog-1.5.6 release, memory I/O optimized version of PHP log extension SeasLog-1.5.6 release, memory and IO optimized version, lightweight and efficient PHP log extension.

Improvement log:

This improves memory stability and batch I/O. this version will reduce memory and I/O consumption, and a performance test report will be released later.

-Fixed issue #76 #80 #86 Fixed segment fault with PHP7.-Make memory usage more stable, and clear memory leaks with PHP5. * and PHP7 .*.

Why use SeasLog

Log logs are generally the running records of systems, software, and applications. Log analysis helps you understand the running status of systems, software, and applications. if your application logs are rich enough, you can also analyze the user's operation behavior, type preferences, region distribution, or other information in the past. if the log of an application is divided into multiple levels, you can easily analyze the health status of the application, identify problems in time, quickly locate and solve problems, and remedy the losses.

The built-in error_log and syslog functions of php are powerful and have excellent performance. However, due to various defects (error_log has no error level and no fixed format, syslog is not divided into modules and mixed with system logs ), flexibility is much lower and cannot meet application requirements.

The good news is that many third-party log class libraries make up for the above defects, such as log4php, plog, and Analog (of course there are also many log classes developed by applications in the project ). Among them, log4php is the most famous, well-designed, well-formatted, well-documented, and powerful. Recommended.

However, log4php performs very poorly in terms of performance. it is the AB concurrent performance test of SeasLog and log4php (test environment: Ubuntu12.04 single-host, CPU I3, 16 GB memory, hard disk SATA 7200 ):

Is there a log class library that meets the following requirements:

  • Modules and levels

  • Easy configuration (preferably not required)

  • Log Format is clear and easy to read

  • Simple application and excellent performance

SeasLog is generated based on this requirement.

What are currently provided

  • Easily and standardizes log recording in PHP projects

  • Configurable default log directories and modules

  • Specify the log directory and obtain the current configuration

  • Preliminary analysis and warning framework

  • Efficient log buffer and convenient buffer debug
  • Compliance with PSR-3 log interface specifications

  • Automatically record error information
  • Automatically record exception information
What is the goal?
  • Convenient and standard log records

  • Efficient massive log analysis

  • Configurable and multi-channel log warning

Install, compile, and install SeasLog
$ /path/to/phpize$ ./configure --with-php-config=/path/to/php-config$ make && make install
Install SeasLog in PECL
$ pecl install seaslog
Seaslog. ini configuration
; Configuration for php SeasLog moduleextension = seaslog. soseaslog. default_basepath =/log/seaslog-test; the default log root directory is seaslog. default_logger = default; default logger directory seaslog. disting_type = 1; whether to split files by type; 1 is 0 No (default) seaslog. disting_by_hour & nnbsp; = 1; whether to divide a file every hour; 1: 0; No (default) seaslog. use_buffer = 1; whether to enable buffer 1 is 0 No (default) seaslog. buffer_size = 100; buffer quantity defaults to 0 (no buffer_size is used) seaslog. level = 0; default log level 0 (all logs) seaslog. trace_error = 1; automatic record error default value: 1 (enabled) seaslog. trace_exception = 0; automatic recording of exception information defaults to 0 (off) seaslog. default_datetime_format = "% Y: % m: % d % H: % M: % S"; default date format configuration "% Y: % m: % d % H: % M: % S"

Seaslog. disting_type = 1. enable file separation by type, that is, the log file distinguishes info \ warn \ erro.

Seaslog. disting_by_hour = 1. enable file division every hour.

Seaslog. use_buffer = 1 enable buffer. Disabled by default. When this option is enabled, logs are pre-stored in memory, and files are written at the end of the request (or when an exception exits.

Constants and functions

Constant list

* SEASLOG_DEBUG "debug" * SEASLOG_INFO "info" * SEASLOG_NOTICE "notice" * SEASLOG_WARNING "warning" * SEASLOG_ERROR "error" * warn "critical" * warn "alert" * warn "emergency" var_dump (SEASLOG_DEBUG, SEASLOG_INFO, SEASLOG_NOTICE);/* string ('debug') debug level string ('info') info level string ('notice ') notice Level */

Function List

SeasLog provides such a set of functions to conveniently obtain and set the root directory, module directory, and fast log writing and statistics. We believe that you can quickly obtain function information from the comments of the following pseudocode:

     

Use of SeasLog Logger (detailed document)

Use SeasLog for health warning

Alert configuration

[Base] wait_analyz_log_path =/log/base_test [fork]; check whether multithreading is enabled; 1. enable 0. disable fork_open = 1; thread count fork_count = 3 [warning] email [smtp_host] = smtp.163.comemail [smtp_port] = 25 email [subject_pre] = warning email-email [smtp_user] = seaslogdemo@163.comemail [smtp_pwd] = seaslog [mail_from] = seaslogdemo@163.comemail [mail_to] = gaochitao@weiboyi.comemail [mail_cc] = ciogao@gmail.comemail [mail_bcc] = [analyz]; enum; SEASLOG_DEBUG "debug"; SEASLOG_INFO "info"; SEASLOG_NOTICE "notice"; SEASLOG_WARNING "warning"; SEASLOG_ERROR "error"; warning "critical"; SEASLOG_ALERT "; SEASLOG_EMERGENCY "emergency" test1 [module] = test/bbtest1 [level] = SEASLOG_ERRORtest1 [bar] = 1test1 [mail_to] = gaochitao@weiboyi.comtest2 [module] = 222test2 [level] = modules [module] = 333test3 [level] = SEASLOG_CRITICALtest4 [module] = 444test4 [level] = SEASLOG_EMERGENCYtest5 [module] = 555test5 [level] = SEASLOG_DEBUG

Crontab configuration

Execute 0 3 ***/path/to/php/path/to/SeasLog/Analyzer/SeasLogAnalyzer. php at every day.

Demo:

  'Neeke'); SeasLog: info ('This is a info log'); SeasLog: notice ('This is a notice log'); SeasLog :: warning ('your {website} was down, please {action} it ASAP! ', Array (' {website} '=>' github. com ',' {action} '=> 'rboot'); SeasLog: error ('a error log'); SeasLog :: critical ('Some thing was critical '); SeasLog: alert ('Yes this is a {messageName}', array ('{messageName}' => 'alertmsg ')); seasLog: emergency ('Just now, the house next door was completely burnt out! {Note} ', array (' {note} '=> 'It's a joke'); echo "\ n ";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.