odi
unread,May 6, 2009, 3:59:55 AM5/6/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Log4erl
hi,
I tried to test performance of log4erl compared to error_logger
logging system. During test I noticed that it would be nice to be able
to turn rotation of files off - it takes some time to check file's
size each time when a message is logged.
I testes error_logger from erlang 5.6.5 (kernel-2.12.5,
stdlib-1.15.5), log4erl-0.8.4 and log4erl-0.8.6 both with and without
rotation. Below are results and source code for test. Logging time in
test is a time diff between start and end of the test while summary
log time is a time measured when all messages were actually logged to
a file on disk.
Logging system rotation logging time in test summary log
time
-----------------------------------------------------------------------------------------------------
error_logger --- 150ms 63s
log4erl-0.8.4 on 594ms 170s
log4erl-0.8.4 off 563ms 75s
log4erl-0.8.6 on 9s 34s
log4erl-0.8.6 off 5s
30s
-----------------------------------------------------------------------------------------------------
Introducing synchronous logging caused speedup in logging file to a
disk but logging time in test is much greater.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% log_test source code
-module(log_test).
-export([log4erl/2, error_logger/2]).
log4erl(Count, Size)->
application:start(log4erl),
%log4erl:add_logger(messages_log),
log4erl:add_file_appender(file, {"../logs", "log4erl", {size,
100000000}, 4, "txt", all}),
log4erl:change_format(file, "%j %T [%L] %l%n"),
Msg = create_msg(Size),
Now = erlang:now(),
io:format("Started logging ~p messages of ~p bytes with
log4erl...~n", [Count, Size]),
do_log(Count, log4erl, info, Msg, Now).
error_logger(Count, Size)->
error_logger:tty(false),
error_logger:logfile({open, "../logs/error_logger.txt"}),
Msg = create_msg(Size),
Now = erlang:now(),
io:format("Started logging ~p messages of ~p bytes with
error_logger...~n", [Count, Size]),
do_log(Count, error_logger, info_msg, Msg, Now).
do_log(0, Module, _Function, _Msg, StartTime) ->
Now = erlang:now(),
Diff = timer:now_diff(Now, StartTime),
io:format("~p logging took ~p ms~n", [Module, Diff/1000]);
do_log(Count, Module, Function, Msg, StartTime) ->
apply(Module, Function, ["~p", [Msg]]),
do_log(Count - 1, Module, Function, Msg, StartTime).
create_msg(Size) ->
create_msg(Size, []).
create_msg(0, Msg) ->
Msg;
create_msg(Size, Msg) ->
Letter = random:uniform(26) + 96,
create_msg(Size - 1, lists:append(Msg, [Letter])).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
regards,
Kuba