Question

I'm creating a site using .Net 4.0 and C# with the MVC2 Framework.

I have 5 different projects under the solution - AdminPresentation, FrontEndPresentation, DataAccessLayer, Business, Tests.

I'm looking to implement a logger that can be used throughout all the layers and was advised that it might be best to include the Logger classes as a Dll and include this in my projects. I'm going to use nLog but I suppose it should be be possible to slot a different logger in if needed (Dependency injection?).

I am new to .NET/C#, any advice/examples/links to sites would be very much appreciated, Specifically how to implement the logger and how to use it as a dll if appropriate.

Thanks

Was it helpful?

Solution

There are many logger abstractions available, no need to roll your own, see Is there a logging facade for the .NET world?

OTHER TIPS

You can create your own ILogger interface and use that throughout your application. In your DI configuration you map the ILogger to a type that knows how to send messages to NLog.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top