当前位置:网站首页>Differences between seaslog and monolog log systems, installation steps of seaslog [easy to understand]
Differences between seaslog and monolog log systems, installation steps of seaslog [easy to understand]
2022-07-25 20:40:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
SeasLog Yes, it is C language-written PHP expanded memory bank , Powerful and high performance monolog It's far worse than this .
Common logging components
Suppose an interface , It says 5 Record log ,
about monolog It is 5 Write to disk operation , That is to say 5 Time IO,
In a high concurrency field , Log is written to disk ,
The disk of the machine IO , The Internet IO, Memory operations Will be right. CPU The load of causes pressure .
Brush the disk frequently ,CPU The occupancy rate will be too high due to log writing , Because of the logic of the interface itself 1. Reading and writing Mysql 2. Reading and writing Redis 3. Queue task There are already many networks IO And disk IO Operation .
that ,seasLog How does it work ? As follows You can customize in the configuration file Every time N Time Log data is written to disk once Store in... Before writing to disk buffer in , In memory For the scene above amount to 5 Secondary disk IO It becomes a disk IO
1. High and sending logs will not become a performance bottleneck second QPS 8000
2. Built in log analysis and warning framework ( Off by default )( Mainly used to analyze Error journal ) A: Count the number of certain log levels B: View all logs at a certain log level C: Send log alarm by email
3. Support each log N Next time , Log data is written to disk ( Log buffer )
4. Support RequestId Request global id Differentiate request
5. Support cutting logs by time
I am a seaslog For the benefit of ,
After using this component , Solved our company's log pair CPU Occupation problem .
There is also the problem of link tracking , Thanks to the ( Overall RequestId)
This good thing , Share it with you .
Personally test the installation steps :
1. Download installation package :
sudo wget https://pecl.php.net/get/SeasLog-2.2.0.tgzdecompression
sudo tar xzvf SeasLog-2.2.0.tgz 2. function phpize, Generate configure Compile the file
3 . To configure
sudo ./configure --with-php-config=/usr/local/php/bin/php-config4. Compile and install
sudo make && make installThe extension is stored in /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ Under the table of contents
5. stay php.ini Add... To the file seaslog Expand
extension=seaslog.so
[SeasLog]
seaslog.default_basepath ="/tmp"
seaslog.default_logger = "default"
seaslog.disting_type = 1
seaslog.disting_by_hour = 1
seaslog.use_buffer = 1
seaslog.buffer_size = 100
seaslog.level = 8
seaslog.trace_error = 1
seaslog.trace_exception = 06. restart PHP
sudo service php-fpm reload7. Running results
<?php
SeasLog::setBasePath('/home/wwwlogs/seaslog');
//echo SeasLog::getBasePath();
SeasLog::setLogger('api');
echo SeasLog::getBasePath();
echo '<br>'.SeasLog::getLastLogger();
SeasLog::debug('test');
SeasLog::debug('this is a debug');
SeasLog::info('this is a info');
SeasLog::notice('this is a notice');
SeasLog::emergency('this is a emergency');
$data=SeasLog::analyzerCount();
echo '<pre>';
print_r($data);
echo '<pre>';
SeasLog::flushBuffer();
//SeasLog::log('info','this is info test');
echo phpinfo();common problem :
1.seaslog.level = 8 Record all log types , Given in muke.com seaslog.level = 0 Record all logs , Just the opposite , This is a pit
; Log level , The greater the number , The more logs recorded according to the level .
;0-EMERGENCY 1-ALERT 2-CRITICAL 3-ERROR 4-WARNING 5-NOTICE 6-INFO 7-DEBUG 8-ALL
; Default 8( All logs )
;
; Be careful , This configuration item is from 1.7.0 The version began to change .
; stay 1.7.0 Before the release , The smaller the number of this value , The more logs recorded according to the level :
; 0-all 1-debug 2-info 3-notice 4-warning 5-error 6-critical 7-alert 8-emergency
; 1.7.0 Previous version , This value defaults to 0( All logs );
seaslog.level = 8
seaslog.level = 8Default logger level.The Default value was 8, it’s meaning SeasLog will record all of the level. Default recorder level default value is 8, It means SeasLog All levels will be recorded .
seaslog.level = 0SeasLog will record which level EMERGENCY.
seaslog.level = 1SeasLog will record which level EMERGENCY,ALERT.
seaslog.level = 2SeasLog will record which level EMERGENCY,ALERT,CRITICAL.
seaslog.level = 3SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR.
seaslog.level = 4SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING.
seaslog.level = 5SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE.
seaslog.level = 6SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE,INFO.
seaslog.level = 7SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG.
2.4.2 Log template description
Template defaults to :seaslog.default_template = “%T | %L | %P | %Q | %t | %M”
The default format is {dateTime} | {level} | {pid} | {uniqid} | {timeStamp} | {logInfo}
Real case :2020-05-09 10:31:58 | DEBUG | 10012 | 5eb6161dd598e | 1588991518.904 | debug journal
If the custom template is :seaslog.default_template = “[%T]:%L %P %Q %t %M”
The custom log format is :[{dateTime}]:{level} {pid} {uniqid} {timeStamp} {logInfo}
Real case :[2020-05-09 10:31:58] :{DEBUG} {10012} {5eb6161dd598e} {1588991518.904}{debug journal }
PS:%L Must be in %M Before , That is, the log level is before the log content .
3.seaslog The common method of
Configuration method :setBasePath,getBasePath,setLogger,getLastLogger
How to log :log,info,notice,debug,warning,error
Log reading method :analyzerCount,analyzerDetail
3.1 List of constants
SeasLog The log is divided into 8 A level
Level | Abbreviation | remarks |
|---|---|---|
SEASLOG_DEBUG | DEBUG | debug Information 、 Fine grained information events |
SEASLOG_INFO | INFO | Important events 、 Emphasize the running process of the application |
SEASLOG_NOTICE | NOTICE | Events of general importance 、 The execution process is relatively INFO Level more important information |
SEASLOG_WARNING | WARNING | There is a non error exception message 、 Potential exception information 、 Need attention and repair |
SEASLOG_ERROR | ERROR | Errors at run time 、 It is not necessary to repair immediately 、 It does not affect the operation of the whole logic 、 It needs to be recorded and tested |
SEASLOG_CRITICAL | CRITICAL | emergency 、 It needs to be repaired immediately 、 Program components are not available |
SEASLOG_ALERT | ALERT | An emergency that requires immediate action 、 It is necessary to immediately notify relevant personnel for emergency repair |
SEASLOG_EMERGENCY | EMERGENCY | System not available |
3.2:SeasLog What is the performance of
A:
When SeasLog Don't open buffer when ,SeasLog yes :syslog() Functional 8.6 times 、file_put_contents() Functional 240 times 、fwrite() In single case 36 times 、fwrite() Not in a single case 211 times 、monolog Don't open buffer At the time of the 41 times ; When SeasLog Turn on buffer And buffer_size by 100 when ,SeasLog yes :syslog() Functional 250 times 、file_put_contents() Functional 6962 times 、fwrite() In single case 1052 times 、fwrite() Not in a single case 6127 times 、monolog Turn on buffer And buffer size by 100 At the time of the 118 times .
Official documents :https://github.com/Neeke/SeasLog/blob/master/README_zh.md
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/111564.html Link to the original text :https://javaforall.cn
边栏推荐
- [leetcode] 28. Implement strstr ()
- [tensorrt] dynamic batch reasoning
- [today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
- DIY personal server (DIY storage server)
- Embedded development: embedded foundation -- threads and tasks
- 【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)
- Kubernetes进阶部分学习笔记
- 7.23
- 网络协议:TCP Part2
- 数据库清空表数据并让主键从1开始
猜你喜欢

Key network protocols in tcp/ip four layer model

Clickhouse notes 02 -- installation test clickvisual

火山引擎项亮:机器学习与智能推荐平台多云部署解决方案正式发布

leetcode-6130:设计数字容器系统

程序的编译和运行

103. (cesium chapter) cesium honeycomb diagram (square)

Leetcode-79: word search

Unity VS—— VS中默认调试为启动而不是附加到Unity调试
![[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance](/img/2d/c23a367c9e8e2806ffd5384de273d2.png)
[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance

Online random coin tossing positive and negative statistical tool
随机推荐
[today in history] June 28: musk was born; Microsoft launched office 365; The inventor of Chua's circuit was born
Detailed explanation of document operation
[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace
Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
【TensorRT】动态batch进行推理
数据库清空表数据并让主键从1开始
Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34
KEGG通路的从属/注释信息如何获取
Vulnhub | dc: 6 | [actual combat]
Struct, enum type and union
[leetcode] 28. Implement strstr ()
Network protocol: TCP part2
Apache Mina framework "suggestions collection"
FanoutExchange交换机代码教程
Illustration leetcode - 3. longest substring without repeated characters (difficulty: medium)
Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework
Online XML to JSON tool
Google guava is just a brother. What is the real king of caching? (glory Collection Edition)
Working principle of radar water level gauge and precautions for installation and maintenance