当前位置:网站首页>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
边栏推荐
- Web crawler principle analysis "suggestions collection"
- Remote monitoring solution of intelligent electronic boundary stake Nature Reserve
- 【TensorRT】trtexec工具转engine
- Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)
- 火山引擎项亮:机器学习与智能推荐平台多云部署解决方案正式发布
- [advanced drawing of single cell] 07. Display of KEGG enrichment results
- Docker 搭建 Redis Cluster集群
- Leetcode-6130: designing digital container systems
- Apache Mina framework "suggestions collection"
- Remote - actual combat
猜你喜欢

【高等数学】【5】定积分及应用

雷达水位计的工作原理及安装维护注意事项

Network protocol: TCP part2
![[advanced mathematics] [8] differential equation](/img/83/b6b07540e3cf6d6433e57447d42ee9.png)
[advanced mathematics] [8] differential equation

Detailed explanation of document operation
![Vulnhub | dc: 6 | [actual combat]](/img/7e/de7d5b56724bde5db2bb8338c35aa8.png)
Vulnhub | dc: 6 | [actual combat]

Introduction and construction of consul Registration Center
![[leetcode] 28. Implement strstr ()](/img/87/0af2da458e53d31012d6535cc132bb.png)
[leetcode] 28. Implement strstr ()

Unity VS—— VS中默认调试为启动而不是附加到Unity调试
[today in history] June 30: von Neumann published the first draft; The semiconductor war in the late 1990s; CBS acquires CNET
随机推荐
[today in history] July 2: BitTorrent came out; The commercial system linspire was acquired; Sony deploys Playstation now
Scan delete folder problems
DIY personal server (DIY storage server)
MPI学习笔记(二):矩阵相乘的两种实现方法
Vulnhub | dc: 5 | [actual combat]
Yolov7 training error indexerror: list index out of range
Leetcode-6125: equal row and column pairs
JMeter - interface test
Increase swap space
Principle analysis of bootloader
Introduction and construction of consul Registration Center
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
Brush questions with binary tree (4)
【NOI模拟赛】字符串匹配(后缀自动机SAM,莫队,分块)
[tensorrt] dynamic batch reasoning
Leetcode-6126: designing a food scoring system
leetcode-6125:相等行列对
2022.7.24-----leetcode.1184
[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
Remote—基本原理介绍