Uninote
Uninote
用户根目录
每日点滴

<!DOCTYPE html> <html><head><meta http-equiv='Content-Type' content='text/html; charset=utf8'><title>php seaslog</title> <script> var g_resRoot = '../../__res/'; var g_json_outline = '{"children":[{"children":[],"level":1,"lvNumber":"1","text":"日志分析demo"},{"children":[],"level":1,"lvNumber":"2","text":"自定义日志模板"},{"children":[],"level":1,"lvNumber":"3","text":"SeasLog 共将日志分成8个级别"},{"children":[],"level":1,"lvNumber":"4","text":"SeasLog 日志收集"}],"level":0,"lvNumber":"","text":"php seaslog"}'; </script> <link rel='stylesheet' type='text/css' href='../../__res/common.css'><style>.s0{color:#000000;} .s1{color:#000000;} .s2{color:#000000;} .s3{color:#000000;} .s4{color:#000000;} .s5{color:#0000ff;} .s6{color:#000000;} .s7{color:#0000ff;} .s8{color:#000000;} </style> </head><body> <script src='../../__res/util.js'></script><div id='outline'> <li><a href='#ol_0' style='font-weight:bold; font-size:22px'>php seaslog</a></li> <li> <a href='#ol_1' >日志分析demo</a></li> <li> <a href='#ol_2' >自定义日志模板</a></li> <li> <a href='#ol_3' >SeasLog 共将日志分成8个级别</a></li> <li> <a href='#ol_4' >SeasLog 日志收集</a></li> </div>

<pre id='ol_0' class='title'>php seaslog</pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>E:\uninote\mynote\basic\web\tests\seaslog.php</d></pre> <pre><d class='s1'>E:\uninote\mynote\basic\runtime\seaslog</d></pre> <pre><d class='s1'>E:\software\programming\php\5.6.30\php_seaslog-1.8.4-5.6-ts-vc11-x64.zip</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s0'>安装 Php模块 seaslog</d></pre> <pre><d class='s1'><a href='http://dev.rongyipiao.com/book/1089785219#362'>http://dev.rongyipiao.com/book/1089785219#362</a></d></pre> <pre><d class='s1'><a href='https://www.imooc.com/qadetail/119739'>https://www.imooc.com/qadetail/119739</a></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>eson 日志系统</d></pre> <pre><d class='s1'>关于使用PHP扩展SeasLog日志系统</d></pre> <pre><d class='s1'><a href='http://dev.rongyipiao.com/book/1092917203#281'>http://dev.rongyipiao.com/book/1092917203#281</a></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>官方文档: SeasLog Supports</d></pre> <pre><d class='s1'><a href='https://github.com/SeasX/SeasLog'>https://github.com/SeasX/SeasLog</a></d></pre> <pre><d class='s1'></d></pre> <pre><d class='s1'>; 注意, 该配置项自1.7.0版本开始有变动。</d></pre> <pre><d class='s1'>; 在1.7.0版本之前, 该值数字越小,根据级别记的日志越多: </d></pre> <pre><d class='s1'>; 0-all 1-debug 2-info 3-notice 4-warning 5-error 6-critical 7-alert 8-emergency</d></pre> <pre><d class='s1'>; 1.7.0 之前的版本,该值默认为0(所有日志);</d></pre> <pre><d class='s1'>seaslog.level = 8</d></pre> <pre><d class='s1'></d></pre> <pre><d class='s2'>SHA-1: 2cde9bd61079f8b464db5536ab306a848dbbd2ec</d></pre> <pre><d class='s2'>* </d><d class='s3'>【更新】</d><d class='s4'>- </d><d class='s3'>统一日志系统</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s2'>SHA-1: fd89d5794a778b9b09ddcd369ad6fe3276d1f1d3</d></pre> <pre><d class='s2'>* </d><d class='s3'>【</d><d class='s4'>bug</d><d class='s3'>】</d><d class='s4'>- </d><d class='s3'>优化重构</d><d class='s4'>seaslog</d><d class='s3'>日志系统代码简化</d></pre> <pre><d class='s0'></d></pre> <t id='9e8d5de4-52a7-45d3-ab26-8ef45cb873d0'> <pre class='tnd_head'>lv1= lv2= type=todo</pre> <pre><d class='s1'>不同的logger如何配置不同的option,如template?</d></pre> <pre><d class='s1'>输出到多个logger? last logger?</d></pre> <pre><d class='s1'>send remote?</d><d class='s5'></d></pre> </t> <pre><d class='s6'></d></pre> <pre><d class='s6'>这个是日志记录时间,也就是记录的git push这条命令执行完成后的时间,而不是执行之前的时间:</d></pre> <pre><d class='s6'><img src='..\pic\d11bef7f4a5e8acaa49d355c6d9f97b8.jpg' /></d><d class='s6'></d></pre> <pre><d class='s7'></d></pre> <pre><d class='s8'></d></pre> <pre><d class='s8'>简单封装,如果设置到/tmp等地方,还需要权限</d></pre> <pre><d class='s8'>SeasLog::setBasePath(DIR . "/../../../../../runtime/seaslog");</d></pre> <pre><d class='s8'>function slog($content, $params = [], $logger = "default")</d></pre> <pre><d class='s8'>{</d></pre> <pre><d class='s8'> SeasLog::info($content, $params, $logger);</d></pre> <pre><d class='s8'>}</d></pre> <pre><d class='s7'></d></pre> <h1 id='ol_1'>日志分析demo</h1> <pre><d class='s0'>http://localhost:222/tests/seaslog.php</d></pre> <pre><d class='s0'><a href='http://dev.rongyipiao.com/tests/seaslog.php'>http://dev.rongyipiao.com/tests/seaslog.php</a></d></pre> <pre><d class='s0'>这个使用find等shell命令来做的,日志大了会有性能问题。</d></pre> <pre><d class='s0'></d></pre> <h1 id='ol_2'>自定义日志模板</h1> <pre><d class='s0'>很多朋友在使用过程中提到自定义日志模板的需求,于是SeasLog自1.7.2版本开始,拥有了这个能力,允许用户自定义日志的模板, 同时在模板中可以使用SeasLog预置的诸多预设变量,参照预设变量表。</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>日志模板说明</d></pre> <pre><d class='s0'>模板默认为:seaslog.default_template = "%T | %L | %P | %Q | %t | %M"</d></pre> <pre><d class='s0'>意味着,默认的格式为{dateTime} | {level} | {pid} | {uniqid} | {timeStamp} | {logInfo}</d></pre> <pre><d class='s0'>如果自定义的格式为:seaslog.default_template = "[%T]:%L %P %Q %t %M"</d></pre> <pre><d class='s0'>那么,日志格式将被自定义为:[{dateTime}]:{level} {pid} {uniqid} {timeStamp} {logInfo}</d></pre> <pre><d class='s0'>预设变量表</d></pre> <pre><d class='s0'>SeasLog提供了下列预设变量,可以直接使用在日志模板中,将在日志最终生成时替换成对应值。</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>%L - Level 日志级别。</d></pre> <pre><d class='s0'>%M - Message 日志信息。</d></pre> <pre><d class='s0'>%T - DateTime 如2017-08-16 19:15:02,受seaslog.default_datetime_format影响。</d></pre> <pre><d class='s0'>%t - Timestamp 如1502882102.862,精确到毫秒数。</d></pre> <pre><d class='s0'>%Q - RequestId 区分单次请求,如没有调用SeasLog::setRequestId($string)方法,则在初始化请求时,采用内置的static char *get_uniqid()方法生成的惟一值。</d></pre> <pre><d class='s0'>%H - HostName 主机名。</d></pre> <pre><d class='s0'>%P - ProcessId 进程ID。</d></pre> <pre><d class='s0'>%D - Domain:Port 域名:口号,如www.cloudwise.com:8080; Cli模式下为cli。</d></pre> <pre><d class='s0'>%R - Request URI 请求URI,如/app/user/signin; Cli模式下为入口文件,如CliIndex.php。</d></pre> <pre><d class='s0'>%m - Request Method 请求类型,如GET; Cli模式下为执行命令,如/bin/bash。</d></pre> <pre><d class='s0'>%I - Client IP 来源客户端IP; Cli模式下为local。取值优先级为:HTTP_X_REAL_IP > HTTP_X_FORWARDED_FOR > REMOTE_ADDR</d></pre> <pre><d class='s0'>%F - FileName:LineNo 文件名:行号,如UserService.php:118。</d></pre> <pre><d class='s0'>%U - MemoryUsage 当前内容使用量,单位byte。调用zend_memory_usage。</d></pre> <pre><d class='s0'>%u - PeakMemoryUsage 当前内容使用峰值量,单位byte。调用zend_memory_peak_usage。</d></pre> <pre><d class='s0'>%C - TODO Class::Action 类名::方法名,如UserService::getUserInfo。</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>mynote:</d></pre> <pre><d class='s0'>;日志格式模板 默认"%T | %L | %P | %Q | %t | %M"</d></pre> <pre><d class='s0'>seaslog.default_template = "%T | %L | %R | %C | %F | %Q | %M"</d></pre> <pre><d class='s0'>datetime level uri class filename reqid message</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>封装之后,需要修改这个(堆栈回溯一层):</d></pre> <pre><d class='s0'>seaslog.recall_depth = 1</d></pre> <pre><d class='s0'></d></pre> <t id='8e58dcac-7192-4da2-bf90-cbe60c638eee'> <pre class='tnd_head'>lv1= lv2= type=</pre> <h1 id='ol_3'>SeasLog 共将日志分成8个级别</h1> <pre><d class='s8'>SEASLOG_DEBUG</d></pre> <pre><d class='s8'>"DEBUG" - debug信息、细粒度信息事件 8</d></pre> <pre><d class='s8'>SEASLOG_INFO</d></pre> <pre><d class='s8'>"INFO" - 重要事件、强调应用程序的运行过程 7</d></pre> <pre><d class='s8'>SEASLOG_NOTICE</d></pre> <pre><d class='s8'>"NOTICE" - 一般重要性事件、执行过程中较INFO级别更为重要的信息 6</d></pre> <pre><d class='s8'>SEASLOG_WARNING</d></pre> <pre><d class='s8'>"WARNING" - 出现了非错误性的异常信息、潜在异常信息、需要关注并且需要修复 5</d></pre> <pre><d class='s8'>SEASLOG_ERROR</d></pre> <pre><d class='s8'>"ERROR" - 运行时出现的错误、不必要立即进行修复、不影响整个逻辑的运行、需要记录并做检测 4</d></pre> <pre><d class='s8'>SEASLOG_CRITICAL</d></pre> <pre><d class='s8'>"CRITICAL" - 紧急情况、需要立刻进行修复、程序组件不可用 3</d></pre> <pre><d class='s8'>SEASLOG_ALERT</d></pre> <pre><d class='s8'>"ALERT" - 必须立即采取行动的紧急事件、需要立即通知相关人员紧急修复 2</d></pre> <pre><d class='s8'>SEASLOG_EMERGENCY</d></pre> <pre><d class='s8'>"EMERGENCY" - 系统不可用 1</d></pre> </t> <pre><d class='s8'></d></pre> <h1 id='ol_4'>SeasLog 日志收集</h1> <pre><d class='s1'><a href='https://github.com/SeasX/SeasLog/blob/master/Specification/SeasLog_Rsyslog_ELK_zh.md'>https://github.com/SeasX/SeasLog/blob/master/Specification/SeasLog_Rsyslog_ELK_zh.md</a></d></pre> </body></html>

mynote_备案

testing

点赞(0) 阅读(46) 举报
目录
标题