Home >Backend Development >PHP Tutorial >High performance php log system analysis

High performance php log system analysis

小云云
小云云Original
2018-03-05 10:40:345148browse

What is a logging system? ?

1. Record system running information

2. Record logs, applications, and security logs

3. The log function should not affect the normal use of users

Why do we need a logging system? ?

1. Understand the system operation

2. Record user operation information

3. Collect data (such as 500 error, how many times it occurs)

Why choose seaslog? ?

1. High performance (written in C language)

2. No configuration required (write to flash memory first, then write to file after reaching a certain amount)

3. Complete functions Simple to use

What are the scenarios for using seaslog in actual projects? ?

1. Record when someone comes.

2, Record what the user sees I didn’t see it. After seeing it, record what I saw

....

Installation:


Note: It is an extension of php, not an ordinary class library

##http://pecl.php.net/ InstallphpExtension and come to this website to find the package



##1. Unzip and switch to

2.

Enter

phpize3, ./configure --with-php-config=

/www/server/php/54/bin/php-config

(where your php-config is located Absolute path)4. make && make install

5.

Modify

php.ini, add the last line extension=seaslog.so


## Note: Print phpinfo() and check

in the browser. It means the installation is successful, but when executing php -m on Linux, it does not work. I don’t know why yet. I hope you know. Leave me a message to add


##seaslog

Common methods:

##https://github.com/SeasX/SeasLog/blob/master/ README_zh.md


# #These methods are static methods and can be called directly. When testing, use the browser to access, or php -fsetBasePath

: Set the path to save the log

SetLogger:

Save different modules to Under different paths

analyzerCount

Log statistics

Use seaslog in the framework

1. First install the php extension (win to install win, linux to install linux)

2. Load the class library from github into the framework using composer or other methods

Then it will be the same as using a normal class library


Idea 1, directly call

Idea 2 in the controller, change the configuration file of log


Then encapsulate it yourself (same as idea 1, also call it directly in the method of the controller or model)


Related recommendations:

Detailed introduction to the log system

Logging system in the PHP framework

Log system in PHP framework, PHP framework log system

The above is the detailed content of High performance php log system analysis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn