Generic ExceptionLogger Class

Hello guys,
Since the Code contribution is currently disabled and in order for the following Code not to get lost i posted it to the WiKi…
the link:

This is a generic Exception Logger class which would allow you to log all of your program exception errors to your choice of destination be it (a TextFile, WebSite, Email and so on…)

usage is very simple:

private static readonly ExceptionLogger Logger = new ExceptionLogger();
        private void ProgramStarted()
//add a Text Logger.. logs errors to a text file
            Logger.AddLogger(new TextFileExceptionHandler() { FileName = @ "\USB\BugReport.txt" });
//add a web site logger, posts error to a website.
Logger.AddLogger(new WebSiteExceptionHandler(){QueryString="bug",Url=""});
//send errors to an email...
Logger.AddLogger(new EmailExceptionHandler(){EmailFrom="myName@",EmailTo="mybugEmail@", EmailServer=""});

//now let's cause an exception:
                throw new ArgumentException("test");
            catch (Exception e)
                Logger.LogException(e, Assembly.GetExecutingAssembly());


You can very easily extending… by adding your classes to log errors your ways… you can log the error to multiple destination as shown in the above example or to to a single destination.

What is missing:
unfortunately netmf doesn’t offer an general exception event that one could hook to… if this was offered it would have made this class even better where it would catch any exception the system may generate without having to wrap it in try {}catch… and calling it the log.exception method… we’ll see what 4.2 brings…

Oh yah please feel free to edit the wiki and extend the code with new loggers if you create one.

i hope you like it.
Please give your feedback.


Download Gadgeteer demo project from here:


Got it. Thanks.

You’re welcome ;), i hope you find it useful.