Microsoft enterprise library has been updated with the support for .net framework 4.0 , supporting for the WinRT is coming, you can check the uservoice to vote for the features you want. Here is the quick tutoria to get started , we run some basic click and point setup, then do the GUI based config. then same basic coding,
you can setup any project and using the NuGet to search enterprise library, then all the available blocks and extensions are there.
Search “Enterprise” in the nuget source, you will see a lot blocks , we pickup the logging block first,
it will show you all the dependencies , here the unity is the IOC Container , common is the shard base library .
Now our project has the required assembilies, Next step, we need one editor to do the configuration. Download and Install this Config Editor. and restart the IDE, then you can right click app.config, and see the editor option with along with the WCF configuration
Now let’s do some basic configuration to turn on the logging. basically we inject some implementation of the logwriter and it’s dependencies for implementations.
click the blocks menu, you will see all the available blocks we can configure. (once we add more nuget package like cryptography , you will see more options in the menu)
by default, it pick up one eventlog listener and using the giving format. . we just leave it as it. then save the config
Now, let’s write a helloword app to write some dummy log.
get a container first, then we can retrieve the logwriter from the contonainer, I will use the unitycontainer.
var container = new UnityContainer();
then let’s get the reference to logwriter. then dump some message,
Run it, we can see the log in the event log there.
Now app is there, we can simply change the config file, and change the log to a text file or event a Database table.
right click the target listener and add, you can see we have several ones. we just pick up the flat file.
and chose the formmater to the default one, which you can config it too, like add more fileds.
Save it and run. we can see the log file called trace.log was generated. with the following contents
if we want to save it to DB, search NUget, and add the logging for db blocks
then we you add log listener, you will see a new one.