erlang应用都会启动一个sasl应用,sasl的一个重要功能便是可以记录系统进程相关日志,如进程启动、结束、崩溃错误等信息。sasl的日志功能是基于erlang自带的日志模块error_logger来实现的. sasl中定义了下面3个错误处理:
error_logger_mf_h :循环日志文件记录
在sasl.erl模块中注册了日志处理句柄,可以找到代码片断
sasl_report_tty_h : 将日志输出到控制台 .
sasl_report_file_h : 将日志输出到单个文件error_logger_mf_h :循环日志文件记录
elog.config
%% rotating log and minimal tty
[{sasl, [
{sasl_error_logger, false},
%% define the parameters of the rotating log
%% the log file directory
{error_logger_mf_dir,"/home/joe/error_logs" },
%% # bytes per logfile
{error_logger_mf_maxbytes,10485760}, % 10 MB
%% maximum number of logfiles
{error_logger_mf_maxfiles, 10}
]}].
$erl -boot start_sasl -config elog
在sasl.erl模块中注册了日志处理句柄,可以找到代码片断