hi folks,
on our current project we decide to use enterprise library for logging, upto now we used only log4net, but I can not find any advice how to really use the library in flexible way, what I mean is in log4net this would be the way:
//define this in MyClass
private static readonly ILog log = LogManager.GetLogger(typeof(MyClass));
//and than in the methods you can call it like this
log.Info("info message");
this would enable me to go to application later and by chainging configuration I could turn info/warn levelels for particular classes without touching the application.
The only sample of logging library is basically this:
LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Priority = 2;
logEntry.Message = "Informational message";
logEntry.Categories.Add("Trace");
logEntry.Categories.Add("UI Events");
Logger.Write(logEntry);
but than I would be bound to filter based on some strings with typos and similar, and every developer would introduce his category-tokens, what is the best way to limit this, what are best practices about constructing messages, on another side above solution is not very developer friendly to require 10 lines for single log message, using some static methods for whole solution would reduce flexibility in filtering, so what is the best way to use logging?
did you found any meaningful pattern how to use it?
thanks almir