0

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

Thomas Buckley
  • 5,836
  • 19
  • 62
  • 110

2 Answers2

0

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.

Steven
  • 166,672
  • 24
  • 332
  • 435
0

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

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275