示例 #3 快速写入日志
SeasLog::log(SEASLOG_ERROR,'this is a error test by ::log');SeasLog::debug('this is a {userName} debug',array('{userName}'=>'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'));?>
日志的默认模板是 seaslog.default_template = "%T | %L | %P | %Q | %t | %M".
这意味着,在默认情况下,日志的记录格式是: `{dateTime} | {level} | {pid} | {uniqid} | {timeStamp} | {logInfo}`.
以上例程的输出类似于:
seaslog.appender = 1
2014-07-27 08:53:52 | ERROR | 23625 | 599159975a9ff | 1406422432.786 | this is a error test by log
2014-07-27 08:53:52 | DEBUG | 23625 | 599159975a9ff | 1406422432.786 | this is a neeke debug
2014-07-27 08:53:52 | INFO | 23625 | 599159975a9ff | 1406422432.787 | this is a info log
2014-07-27 08:53:52 | NOTICE | 23625 | 599159975a9ff | 1406422432.787 | this is a notice log
2014-07-27 08:53:52 | WARNING | 23625 | 599159975a9ff | 1406422432.787 | your github.com was down,please rboot it ASAP!
2014-07-27 08:53:52 | ERROR | 23625 | 599159975a9ff | 1406422432.787 | a error log
2014-07-27 08:53:52 | CRITICAL | 23625 | 599159975a9ff | 1406422432.787 | some thing was critical
2014-07-27 08:53:52 | EMERGENCY | 23625 | 599159975a9ff | 1406422432.787 | Just now, the house next door was completely burnt out! it is a joke
以上例程的输出类似于:
seaslog.appender = 2 or seaslog.appender = 3
The log style finally formatted such as:
<15>1 2017-08-27T01:24:59+08:00 vagrant-ubuntu-trusty test/logger[27171]: 2016-06-25 00:59:43 | DEBUG | 21423 | 599157af4e937 | 1466787583.322 | this is a neeke debug
<14>1 2017-08-27T01:24:59+08:00 vagrant-ubuntu-trusty test/logger[27171]: 2016-06-25 00:59:43 | INFO | 21423 | 599157af4e937 | 1466787583.323 | this is a info log
<13>1 2017-08-27T01:24:59+08:00 vagrant-ubuntu-trusty test/logger[27171]: 2016-06-25 00:59:43 | NOTICE | 21423 | 599157af4e937 | 1466787583.324 | this is a notice log