Per-module loglevel on ejabberd

The next ejabberd release will include a much useful feature thanks to Andreas Köhler: you will be able to set a different loglevel for any given module.

ProcessOne
· 1 min read
Send by email

The yet powerful ejabberd has received a new very useful feature: per-module loglevel. This means it is possible to set different the loglevel for different modules.

It is very useful for:

  • debugging: just raise the loglevel for the module(s) in the areas where you need to investigate
  • scalability: since I/O are very consuming, it is mandatory to lower to minimum the log files throughput selectively

And of course it comes with live change of this loglevel!

Extract from the documentaiton:
The option {loglevel} modifies the verbosity of the file ejabberd.log. The syntax is one of:
{loglevel, Level}. The standard form to set a global log level (From 0 to 5, the most verbose).
{loglevel, {Level, [{Module, Level}, ...]}}. The given Erlang modules will be logged with specific log levels, all others will use the default log level.

for changing loglevel dynamically, you can use:
ejabberd_loglevel:set(3).
or
ejabberd_loglevel:set({3, [{ejabberd_c2s, 5}]}).
3 being the default loglevel.

If you need, you can also have a look at the ejabberd_loglevel:set_custom/2 and ejabberd_loglevel:clear_custom/0 function for more advanced usage.

This change is already available to git users, and it will be available later on the next release. Per module loglevel is still in beta, so do not hesitate to report error, strange behaviour and suggestion.