Synopsis

Why use seaslog

The log journal，which is usually the operate record of the system，software and the application record. Through the analysis of the log，it can facilitate users to understand the operation of the system，software and the application situation. If your application log is rich enough，it can also analyze the previous use’s operation behavior，type ，regional distribution or other more information. The application log also points the multiple levels at the same time, you can easily get the application analysis of health status, timely find problems and quick positioning, and solve the problem, remedy the loss.

The error_log, syslog function which built in PHP is powerful and excellent performance, but due to various defects (error_log have no error level, no fixed format, syslog regardless of module, and mix with system log ), reducing a lot of flexibility , and can't meet the application requirements.

The good news is that there are a number of third-party log class library established to make up for the defects, such as log4php, plog, Analog (of course, there are many applications in the project development of the log class). Of which log4php is the most famous and excellent design, perfect document format , powerful function，which is recommanded.

seaslog.disting_folder = 1 Switch use Logger DisTing by folder, it’s meaning SeasLog will create the file deistic by folder, and when this configure close SeasLog will create file use underline connect Logger and Time like default_20180211.log.

seaslog.disting_type = 1 Switch use Logger DisTing by type, it’s meaning SeasLog will create the file deistic info\warn\error and the other type.

seaslog.disting_by_hour = 1 Switch use Logger DisTing by hour. It’s meaning SeasLog will create the file each one hour.

seaslog.use_buffer = 1 Switch the configure use_buffer on. The use_buffer switch default off. If switch use_buffer on, SeasLog prerecord the log with memory, and them would be rewritten down into the Data Store by request shutdown or php process exit (PHP RSHUTDOWN or PHP MSHUTDOWN).

seaslog.buffer_size = 100 Configure the buffer_size with 100. The buffer_size default 0, it’s meaning don’t use buffer. If buffer_size > 0, SeasLog will rewritten down into the Data Store when the prerecorded log in memory count >= this buffer_size,and then refresh the memory poll.

seaslog.level = 8 Default logger level.The Default value was 8, it’s meaning SeasLog will record all of the level.

seaslog.level = 0 SeasLog will record which level EMERGENCY.

seaslog.level = 1 SeasLog will record which level EMERGENCY,ALERT.

seaslog.level = 2 SeasLog will record which level EMERGENCY,ALERT,CRITICAL.

seaslog.level = 3 SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR.

seaslog.level = 4 SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING.

seaslog.level = 5 SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE.

seaslog.level = 6 SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE,INFO.

seaslog.level = 7 SeasLog will record which level EMERGENCY,ALERT,CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG.

seaslog.throw_exception = 1 Open an exception that throws the SeasLog to throw itself. When the directory authority or the receive server port is blocked, throw an exception; do not throw an exception when closed.

seaslog.ignore_warning = 1 Open a warning to ignore SeasLog itself. When directory permissions or receive server ports are blocked, they are ignored; when closed, a warning is thrown.

Custom log template

Many friends mentioned the need for custom log templates during their use,
so SeasLog began with the 1.7.2 version and has the ability to allow users to customize the template for the log.

At the same time, many preset variables that are preset by SeasLog can be used in the template,please referenceDefault variable table。

%Q - RequestId. To distinguish a single request, such as not invoking the SeasLog::setRequestId($string) function，the unique value generated by the built-in static char *get_uniqid () function is used when the request is initialized.。

%H - HostName.

%P - ProcessId.

%D - Domain:Port. Such aswww.cloudwise.com:80; When Cli, Such as cli.

%R - Request URI. Such as/app/user/signin; When Cli it's the index script, Such as CliIndex.php.

%m - Request Method. Such asGet; When Cli it's the command script, Such as /bin/bash.

SEASLOG_EMERGENCY

Function list

SeasLog provides such a set of functions that you can easily get and set the root directory, log module directory, fast write and statistics.
Believe that from the following pseudo code comments, you can quickly get function information, specific use will follow.

Switch Default seaslog.disting_type = 0, If we used SeasLog today, the log file will been finally :

LogFile = basePath / logger / 20140218.log

If seaslog.disting_type = 1, the log file would be looks like

infoLogFile = basePath / logger / 20140218.INFO.log

warnLogFile = basePath / logger / 20140218.WARNING.log

erroLogFile = basePath / logger / 20140218.ERROR.log

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'));/*These functions can receive `logger` cased by the third param all the time.Tips: `last_logger == ‘default’` will be used same to:SeasLog::setLogger('test/new/path');SeasLog::error('test error 3');The `logger` cased by the third param would be used right this right now, like a temp logger, when the function SeasLog::setLogger() called in pre content.*/