sblog.net
sblog.net copied to clipboard
Provide the ability to log to various formats [txt, database etc] for debugging
Provide the ability to log to various formats [txt, database etc] for debugging. This could be done using MEF, so that the logging could be done optionally, if required. So, this would require the following:
(1) Create a ILogger interface w/in sBlog.Net.Extensibility
(2) Modify NinjectControllerFactory.cs
. After the controller instance is created, compose that instance.
(3) Add imports in the base controller, provide a method to log (virtual methods)
(4) Add logging statements as required
Based on @shiggan arguments, check if you could just use log4net/ nlog.
May I suggest that you stick to one of the bigger supported logging frameworks (nlog, log4net) and refrain from 'wrapping' a logger (usually for later extensibility... later usually never happens btw).
I do application-support for a living; I spend my days diving deep into 'architectural' systems squashing bugs; making clients happy; and moving on.
One thing I see too often is either hacked up loggers that plainly dont work; or work very very badly. Then there are the people who wrap loggers; usually they end up doing it wrong. Wrap log4net yourself and try to get any sensible diagnostic information out of it like method name, line number, class, - hint; you wont - hint x 2 you wont because of the stack trace; you end up getting diagnostics form your wrapper.
You want the ability to target various formats; both nlog and log4net have the concept of a 'target' or 'appender' where you can write custom code to log to the thing you want to log too. I know NLog has the ability for you to capture any sort of information (say the Application Context) into your log - these systems are heavily tested; and widely used; save yourself some grief and don't write your own.
@shiggan Actually, you've got a point. I was not planning to create a logger from scratch. But as you say, my intention was to use this as a wrapper for a fully fledged logger. I understand your reasoning, so, updating this enhancement! Thanks for your views!
I would be happy to help if you run into difficulty with putting together a custom target (nlog) or need to implement a custom formatter (again nlog) - while I have used log4net before its been a very long time on that platform.
@shiggan Sure, thanks!