How do you configure and enable log4net for a stand-alone class library assembly?

前端 未结 6 1252
走了就别回头了
走了就别回头了 2020-12-13 04:02

Background

I am writing a class library assembly in C# .NET 3.5 which is used for integration with other applications including third-party Commercial-Off-The-Shel

6条回答
  •  青春惊慌失措
    2020-12-13 04:57

    In your standalone class library, have a singleton which loads the log4net configuration file using the log4net.Config.XmlConfigurator.

    Specifically, you can define all of your code to use your own custom logging class; this class can just be a simple wrapper of the log4net logging calls, with one addition; make a static member which contains the log information you want to log to; initialize that with a call to the XmlConfigurator in the static constructor for that class. That's all you have to do.

提交回复
热议问题