1
votes

I have a WCF service, on which I would like to implement log4net logging. I added the dll, created log4nrt.config file, created Logger.cs file, modified the web.config. Now problem is my application doesnt have AssemblyInfo.cs file.

Is there a way I can implement log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] somewhere else instead of AssemblyInfo.cs. If so how can I do it?

Thanks

2

2 Answers

0
votes

You can do it in a global.asax file, which is a way to add application-wide code to your service (as well as for asp.net projects)

Add your log4net configuration in the class deriving from HttpApplication (usually the global.asax comes with an Application_Start method ready to be completed with your code)

0
votes

I'm not sure how you managed to create a project without an AssemblyInfo file, but you can add assembly attributes to any class file included in the project:

Log4NetAssembly.cs:

// Can't use using statements..

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", 
                                          Watch = true)]