Every project needs logging functionality of some form. Logging in my case is the ability to persists information beyond the app lifecycle, a debugging session or even multiple app runs. The easiest way to persists information is to write them to a file. The file option makes the export and evaluation of the information easy and straight forward.
For the ease of use you can just call a static method to write to the log file. Like so.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logger.FileLogger.Debug("App started."); |
Is that simple, or not?
Why talking and blogging about something that simple as that tiny library? Well, I’m working everyday with huge libraries like Spring.net, the Enterprise Library and the WPContrib. They are all great and offer a huge set of functionality. On the other hand, with many features comes a lot of overhead that is not necessary all the time. Sometimes you just need a logger, a converter or a json serializer.
Making it all Open Source
For the sake of collaboration and constant improvements, I open sourced the library and put it on GitHub. Have a look, create a pull request, when you need more functionality out of the box. Leave your concerns and ideas for improvements.Putting it up on NuGet for ease of use
To make it even easier to use I also put it on nuget, so it’s only once click away from your project in Visual Studio. Just go to Project –> Manage NuGet Packages and search for “WPFileLogger”.How to use the logger
Using as as simple as calling the static method like this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logger.FileLogger.Debug("App started."); |
Keine Kommentare:
Kommentar veröffentlichen