Quickstart tutorial into Enterprise Library logging

You may also like...

22 Responses

  1. Nathan Prather says:

    Thanks, I’ll read this before implementing on my next project!

  2. Deidn says:

    Thanks, good tutorial

  3. Dries says:

    Is there a trace-listener for the console?
    I’d like do a ‘logger.write’ to both a file and the console.

  4. Maxime Lebel says:

    Is there a way to write on the log specifying the log category (routing) ?

    Something like : logger.write(‘Hello World’, WorldCategory)



  5. Dennis van der Stelt says:

    @Maxime : Yes there is, just like you write… You just need some additional quotes, like:

    Logger.Write(“Hello World”, “WorldCategory”);

    Where I talk about configuration, under “category sources” I talk about the “General” category. This is the default. You can create more categories. Normally I use on for logging/tracing and another one for exceptions. Both write to a rolling-file but both with a different filename.



  6. Gangadhar says:

    A perfect stater for a beginner like me – Thanks a lot

  7. Anders Ericsson says:

    Exactly what I needed to get started with EL. Great job! Missed this in the EL documentation! This should have been the first subject in the documentation! Gets you going in 5 minutes!

  8. Good Post.Its really interesting.

  9. Hitu says:

    Excellant tutorial. Can you pls give a tutorial for Database trace listener.

  10. crazyfire says:

    In the beginning of this article you mentioned something like “your students”. I am curious, if you offer any online courses which i am very much willing to register for.

    Please advice me.

    But Thanks a lot for this article.

  11. Dennis van der Stelt says:

    Sorry, no online training…

    You can ask me questions via the contact page any time you’d like, or check out http://www.pluralsight.com for online training. Those are quite good.

  12. Tom says:

    I am not able to find the log file. No errors. But log file is missing!!

  13. Aoe says:

    Same here. No log file!

  14. Dennis van der Stelt says:

    Some possibilities:

    1) Permissions
    You don’t have permission to write on disk?!
    Also check under which user the process is running. For example if it’s a website that’s logging, it’s probably “Network Service” and if it’s a Windows Service it’s possibly “Local System”

    2) Configuration
    Something with configuration is wrong. EntLib is throwing exceptions. It wants to log these, but no listener is configured.
    Under “Logging Application Block”, under “Special Sources”, under “Logging Errors & Warnings” make sure there’s a trace listener that can ALWAYS write. If EntLib throws exceptions, it uses that trace listener to notify you about it.

  15. Bulldog says:

    Amazing. I just spent 4 hours fighting with the Application Blocks, and you got me where I needed to be in 5 minutes.


    Can I recommend doing one with the Exception Block that logs to a SQL server?

  16. Sachin Arora says:

    Awesome Post sir

  17. vin says:

    To “Aoe”:

    you can simply create your won rolling.log in the application folder and give its path in your listener.

  18. Dan says:

    make sense, easy to understand. nice posting..

  19. Alison says:

    Is it possible to easily change this to write to a log file instead of the event viewer?

  20. Dennis van der Stelt says:

    @Alison : Yes

  21. IamaC says:

    Thanks for the nice tutorial you posted here. Helped me big time.

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *