[erlang-questions] is there any logging module for erlang?

14 views
Skip to first unread message

devdoer bird

unread,
Jun 11, 2008, 11:13:30 PM6/11/08
to erlang-q...@erlang.org
Hi:
 
I wonder whether any logging module for erlang exists,like python's logging module which support :critical level setting ,filtering ,diffrent handlers (stream handler,socket handler,ram handler,file handler...).
 
Thanks a lot!

Pablo Polvorin

unread,
Jun 11, 2008, 11:52:45 PM6/11/08
to erlang-q...@erlang.org
Hi,
did you tried to use the the error_logger module, in the standard OTP distribution?
http://www.erlang.org/doc/man/error_logger.html

also the the report browser is quite useful
http://www.erlang.org/doc/man/rb.html

cheers.
pablo

2008/6/12 devdoer bird <devd...@gmail.com>:
Hi:
 
I wonder whether any logging module for erlang exists,like python's logging module which support :critical level setting ,filtering ,diffrent handlers (stream handler,socket handler,ram handler,file handler...).
 
Thanks a lot!

_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions



--
--
pablo
http://ppolv.wordpress.com
----

devdoer bird

unread,
Jun 12, 2008, 12:15:55 AM6/12/08
to Pablo Polvorin, erlang-q...@erlang.org
Thanks.
I've seen the error logger,but I  need code something to make It support ciritcal levelt setting(info/debug/warming/error)  and filterting(which can define conditions control  whether one specific log record should be printed )
 
What I need is more like log4cpp or python's logging module.
 
And I've stolen some logging code from couchdb and ejabbered ,but they only support critical level setting .
 
Is any other logging package you guys know?
 
2008/6/12, Pablo Polvorin <pablo.p...@gmail.com>:

Ulf Wiger (TN/EAB)

unread,
Jun 12, 2008, 2:03:47 AM6/12/08
to devdoer bird, erlang-q...@erlang.org
devdoer bird skrev:

> Thanks.
> I've seen the error logger,but I need code something to make It support
> ciritcal levelt setting(info/debug/warming/error) and filterting(which
> can define conditions control whether one specific log record should be
> printed )
>
> What I need is more like log4cpp or python's logging module.
>
> And I've stolen some logging code from couchdb and ejabbered ,but they
> only support critical level setting .
>
> Is any other logging package you guys know?

You can take a look at how mnesia does it.
Basically, it's this code in mnesia_lib.erl.

BR,
Ulf W


report_system_event({'EXIT', Reason}, Event) ->
Mod = mnesia_monitor:get_env(event_module),
case mnesia_sup:start_event() of
{ok, Pid} ->
link(Pid),
gen_event:call(mnesia_event, Mod, Event, infinity),
unlink(Pid),

%% We get an exit signal if server dies
receive
{'EXIT', Pid, _Reason} ->
{error, {node_not_running, node()}}
after 0 ->
gen_event:stop(mnesia_event),
ok
end;

Error ->
Msg = "Mnesia(~p): Cannot report event ~p: ~p (~p)~n",
error_logger:format(Msg, [node(), Event, Reason, Error])
end;
report_system_event(_Res, _Event) ->
ignore.

%% important messages are reported regardless of debug level
important(Format, Args) ->
save({Format, Args}),
report_system_event({mnesia_info, Format, Args}).

%% Warning messages are reported regardless of debug level
warning(Format, Args) ->
save({Format, Args}),
report_system_event({mnesia_warning, Format, Args}).

%% error messages are reported regardless of debug level
error(Format, Args) ->
save({Format, Args}),
report_system_event({mnesia_error, Format, Args}).

%% verbose messages are reported if debug level == debug or verbose
verbose(Format, Args) ->
case mnesia_monitor:get_env(debug) of
none -> save({Format, Args});
verbose -> important(Format, Args);
debug -> important(Format, Args);
trace -> important(Format, Args)
end.

%% debug message are display if debug level == 2
dbg_out(Format, Args) ->
case mnesia_monitor:get_env(debug) of
none -> ignore;
verbose -> save({Format, Args});
_ -> report_system_event({mnesia_info, Format, Args})
end.

devdoer bird

unread,
Jun 12, 2008, 9:36:48 AM6/12/08
to Ulf Wiger (TN/EAB), erlang-q...@erlang.org
thanks but it also doesn't support log filtering.
Here is the explanation of filtering from python manual.
"

Filters can be used by Handlers and Loggers for more sophisticated filtering than is provided by levels. The base filter class only allows events which are below a certain point in the logger hierarchy. For example, a filter initialized with "A.B" will allow events logged by loggers "A.B", "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If initialized with the empty string, all events are passed.

class Filter( [name])
Returns an instance of the Filter class. If name is specified, it names a logger which, together with its children, will have its events allowed through the filter. If no name is specified, allows every event.

filter( record)
Is the specified record to be logged? Returns zero for no, nonzero for yes. If deemed appropriate, the record may be modified in-place by this method.

"
 I think I need write one by myself.
Thank you .

 
2008/6/12, Ulf Wiger (TN/EAB) <ulf....@ericsson.com>:

Dave Smith

unread,
Jun 12, 2008, 10:39:07 AM6/12/08
to devdoer bird, erlang-q...@erlang.org
I think it might be worth noting that Erlang provides some powerful
runtime tracing tools. Where in python/java/c++ I would litter my code
with logging statements to keep track of what's happening where, I
find myself not needing that as much, since I can simply throw a trace
on the things I'm interested in, when/if there are problem. That's why
(I think) erlang is so light on logging subsystems.

Just a thought.. :)

D.

2008/6/12 devdoer bird <devd...@gmail.com>:

devdoer bird

unread,
Jun 12, 2008, 11:02:47 AM6/12/08
to Dave Smith, erlang-q...@erlang.org
you mean "erlang:trace(PidSpec, How, FlagList)" ,"erlang:trace_pattern(MFA, MatchSpec, FlagList)" ?

2008/6/12, Dave Smith <diz...@gmail.com>:

Dave Smith

unread,
Jun 12, 2008, 11:11:42 AM6/12/08
to devdoer bird, erlang-q...@erlang.org
Actually, I was referring to the dbg module in runtime_tools. Also the
sys module in stdlib can be helpful when poking around OTP processes.

>From my perspective, Erlang has a very different take on logging due
to the fact that you can easily hop on a live system via a shell and
introspect without stopping. Other languages/platforms don't really
have the idea of being able to hook into the live system with a shell
and poke around. Obviously, this can be dangerous, but at the same
time it's something you simply MUST be able to do if you seriously
want your system to stay up.

There's always a place for error and/or transaction logging, of
course. But for the vast majority of "debug" logs, I find that tracing
can do the trick and help me work out exactly what's happening with my
system without requiring me to litter the code with io:format/2.
Perhaps I'm in the minority, but that's been my experience with
erlang. :)

D.

attila.ra...@ericsson.com

unread,
Jun 12, 2008, 11:31:17 AM6/12/08
to erlang-q...@erlang.org
On Thu, 12 Jun 2008, Dave Smith wrote:

> I think it might be worth noting that Erlang provides some powerful
> runtime tracing tools. Where in python/java/c++ I would litter my code
> with logging statements to keep track of what's happening where, I
> find myself not needing that as much, since I can simply throw a trace
> on the things I'm interested in, when/if there are problem. That's why
> (I think) erlang is so light on logging subsystems.

Logging is useful to detect errors in the first place (see the other
thread where the bug wasn't noticed until the logfiles were read).
tracing is useful if it's known that there's an error, but it's not
clear that where that error actually is.

Bye,NAR
--
"Beware of bugs in the above code; I have only proved it correct, not
tried it."

devdoer bird

unread,
Jun 12, 2008, 10:54:14 PM6/12/08
to attila.ra...@ericsson.com, erlang-q...@erlang.org
Thanks for your info.

Ahmed Ali

unread,
Jun 14, 2008, 9:34:08 AM6/14/08
to devdoer bird, erlang-q...@erlang.org
Hi,

I understand what you want. Having used log4j myself, I've tried to
find something similar for my own. Eventually, I had to write it
myself. This module only supports file logs but it also have support
for multiple log levels, including critical (fatal) level, different
loggers for different modules, size-based rotation...etc.

I haven't shared the project yet, as it has some shortcomings I need
to address before releasing it, however, I'll announce it soon. I hope
this is what you're look for. I'll keep you updated.

Best regards,

Ahmed Al-Issaei

2008/6/12 devdoer bird <devd...@gmail.com>:

Serge Aleynikov

unread,
Jun 14, 2008, 11:30:06 AM6/14/08
to devdoer bird, erlang-q...@erlang.org
In jungerl you can find a lama contribution, which installs an event
handler that supports various severity levels (just like syslog) and
sends reports to syslog.

For a while now I've been planning to update that contrib with the newer
version of lama that supports pluggable logging destinations of two types:
1. Single-line logger (e.g. syslog) that formats the error
reports in one line
2. Multi-line logger (e.g. console) that writes the report to
a destination similar to how SASL does it.

Will try to push this version out when I find some time. Maybe within a
month or so.

Serge

> ------------------------------------------------------------------------

devdoer bird

unread,
Jun 17, 2008, 9:49:12 AM6/17/08
to Ahmed Ali, erlang-q...@erlang.org
yes, that's the one I need.
 
2008/6/14, Ahmed Ali <ahmed....@gmail.com>:

Ahmed Ali

unread,
Jun 21, 2008, 9:00:29 AM6/21/08
to devdoer bird, erlang-q...@erlang.org
Hi,

Sure. Let me clean up my code and then post it somewhere in the
internet. I'll do that within the coming week.

Best regards,

Ahmed Al-Issaei

Ahmed Ali

unread,
Jun 25, 2008, 8:00:19 AM6/25/08
to devdoer bird, erlang-q...@erlang.org
Hi,

You can find this logging module in:
http://code.google.com/p/log4erl/. Please let me know if it didn't
work. You can find instructions for using it in "README.txt" in the
downloaded file.

Best regards,

Ahmed Al-Issaei

devdoer bird

unread,
Jun 27, 2008, 12:39:34 PM6/27/08
to Ahmed Ali, erlang-q...@erlang.org
OK. Thanksvery much. I'll check it then.

2008/6/25, Ahmed Ali <ahmed....@gmail.com>:
Reply all
Reply to author
Forward
0 new messages