I have following requirement.
For simplicity Lets say my solution consists of two projects.
- A Class library Project wrapping Log4Net Functionality.
- A MVC web application project as calling app to class library logger methods which in turn should call log4net actual methods.
I wanted to specify log4net config in the class library app.config file or a xml file in this project.
I read the simlar issue at this thread How do you configure and enable log4net for a stand-alone class library assembly?
But the solution of putting the following two lines in Assembly.info file of my classlibray project didn't work for me.
[assembly: log4net.Config.Repository("ClassLibrary1")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "ClassLibrary1.config", Watch = true)]
As Log4Net is unable to find the related configuration.
For records the name of my class library assembly = ClassLibrary1
I am referring this library from my mvc web app project.
Any ideas why the solution2 as in thread How do you configure and enable log4net for a stand-alone class library assembly?
is not working for me?
Edit:
My program flow is like this.
My MVC app starts.
Unity injects a singleton instance of my log4netwrapper through constructor injection successfully.
Then in a action method i make a call to logger through my wrapper. In the wrapper constructor I make the XmlConfigurator.
Please note while calling i am not supplying the fileinfo object as path to read config entry. For that purpose only in my wrapper assembly
[assembly: log4net.Config.Repository("ClassLibrary1")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "ClassLibrary1.config",
Watch = true)].
Any solutions here?