I am working on a solution on Visual Studio 2008, .NET Framework 3.5, Windows 7. I created a log4net library that writes to a txt file and wants to use it in several projects on my solution, as well as on the wcf service, which is in the same solution that runs locally from a visual studio.
I run the program from the console application in the solution. And the console application invokes other projects, and these projects use log4net. At this level, the journal writes excellently in the workflow. The problem occurs when the wcf service is called. The wcf service uses logging, but log4net does not write to the file.
In a console project, I have the following:
In AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
In App.config, I have a log4net configuration.
In Program.cs by the main method, I:
LogManager.GetLogger("Initialise log4net from the current assembly attributes");
In the WCF service, I have the following:
Same thing in AssemblyInfo.cs as in a console project.
Same thing on Web.config as App.config in the console project.
In the constructor of Service1.svc, I have:
LogManager.GetLogger("Initialise log4net from the current assembly attributes");
This is how my App.config and Web.Config applications look like:
inside the configSections tag:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
and inside the main configuration tag:
<log4net> <root> <level value="DEBUG"/> <appender-ref ref="LogFileAppender" /> </root> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" > <file value="C:\test3.txt"/> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="5" /> <maximumFileSize value="10MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d [%t] %-5p %c %m%n" /> </layout> </appender> </log4net>
How can i solve this?