[Banshee-List] Logging in Banshee: use log4net?



Hello,
I've seen several e-mails and changelog items that raise issues about
logging in Banshee.

Right now, most developers seem to use Console.WriteLine for debugging
(and sometimes check it in by accident :-) ) rather than the Banshee
logger. There are a lot of try catch where the exception thrown is never
logged.

Getting the right log for users is not easier. As you can see in the
thread  "[Banshee-List] howto avoid creating dirs on flash mp3 player",
a user has to put a Console.WriteLine at the right place in the right
file to get critical information about an issue.

Log4net (http://logging.apache.org/log4net/) is a managed logging system
available on both Windows and Linux that works great for Mono. It has a
couple of nice features:
* similar to the logger in Banshee in the way you use it:
log4net.Debug("message"); log4net.Warning("message"); ...
* can be configured by an XML fine. You can define what you want to log
besides the message: thread number, time stamp, namespace, class, etc.
* in the configuration file, you can define different type of output
(file, database, console, SMTP, remote server, etc. or a combination of
several outputs), what level of debug you want to output for certain
namespaces or classes, etc.
* the configuration file can be dynamically changed during runtime

I see a lot of advantages for both developers and users:
* developers can put a lot more debug information that they do now, this
make a lot easier to debug their piece of code. It would also be much
easier for other developers to see how somebody else's ode behaves.
* no more try catch without logging the exception
* banshee can be shipped with a config file that logs nothing or only
the critical debug messages
* if a developer or a user need more debug information, he can modify
the config file to get the logs for the class/namespace/plugin he is
interested in.

For example, to reply to the thread "[Banshee-List] howto avoid creating
dirs on flash mp3 player", a developer could send a new log4net config
file to the user to get the right debug information.

If log4net is defined as a static variable, all plugins can use it by
adding just one line:
private static readonly ILog log4net =
LogManager.GetLogger(typeof(MyClass));
and the config file will be shared by all plugins.

What are your thoughts? I can give you some examples of configuration
files for log4net, or pieces of code that use log4net.

I think the effort of integrating log4net to banshee is very small. and
I would be more than happy to contribute.


Julien Sobrier



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]