[MonoDevelop] Logging in MonoDevelop / Addins

Matze Braun matze at braunis.de
Sat Mar 11 08:45:16 EST 2006


I just wondered why monodevelop defines these ILoggingService classes
just to pipe the messages down to log4net again. Wouldn't it make more
sense to simply use log4net everyhwere instead of having an own
class/interface?

The problem I have with ILoggingService is that I'd like to have log
messages per namespace/class. With log4net this is easy, I just have to
copy that same line that initalized the log into each class:

public MyClass {
	private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

	public void blup() {
		log.info("Some Message");
		log.info("Another message");
	}
}

With the ILoggingService this boilds down to something like this:

public MyClass {
	public void blup() {
		Runtime.Logging.info("MyClass", "Some Message");
		Runtime.Logging.info("MyClass", "ANother message");
	}
}

The need to specify "MyClass" at each log message is annoying, it's easy
to make typos and internally this always results in a
LogManager.GetLogger("MyClass"); which might be costly...

Wouldn't it make more sense to just promote direct log4net usage in
monodevelop?

Greetings,
	Matze




More information about the Monodevelop-list mailing list