Cannot get Log4Net to work in our WCF application

We are trying to use Log4Net to register from our WCF application deployed by IIS 6. We are trying to enter the file, but cannot force the log files to be created, not to mention seeing the log output in them. Relevant out.config fragments:

<sectionGroup name="common"> <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> </sectionGroup> ... <common> <logging> <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging"> <arg key="level" value="INFO" /> <arg key="showLogName" value="true" /> <arg key="showDataTime" value="true" /> <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" /> </factoryAdapter> </logging> </common> <log4net> <appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> <param name="File" value="c:\logs\ApplicationInfoTest.log" /> <threshold value="INFO" /> <param name="AppendToFile" value="true" /> <param name="DatePattern" value="ddMMyyyy" /> <param name="MaxSizeRollBackups" value="10" /> <param name="MaximumFileSize" value="10MB" /> <param name="RollingStyle" value="Size" /> <param name="StaticLogFileName" value="true" /> <layout type="log4net.Layout.PatternLayout"> <param name="Header" value="\r\n\r\n---------------------------------------------\r\n" /> <param name="Footer" value="\r\n---------------------------------------------\r\n\r\n" /> <param name="ConversionPattern" value="%d [%t] %-5p - %m%n" /> </layout> </appender> <root> <level value="INFO" /> <appender-ref ref="FileAppender" /> </root> </log4net> 

With this configuration, we can see how INFO-level logging exits our application when using DebugView, but it is clear that this is from a piece, not a piece.

Is there something we were unable to install in web.config? Is this a permissions issue for the directory we created for recordable logs?

Please indicate our obvious mistake.

+6
c # web-config log4net iis-6
source share
5 answers

Use ProcessMonitor from SysInternals to find out where permissions fail

(You can potentially define the same information by adding a debugger and a trap on exceptions, rather than in Just My Code)

Are you sure that the process in which the service is running has rights to the folder you are trying to write?

+5
source share

I also had to add this line to my application's AssemblyInfo.cs file to get log4net to work.

 // LOG 4 net config [assembly:log4net.Config.XmlConfigurator(Watch=true)] 
+8
source share

Try XmlConfigurator.Configure ()

+2
source share

Do you have a configuration section configured for log4net? I did not see this in the code snippet

0
source share

First, I start the WCF service as a console application - this way you can specify the user account to run the application and check if there is a problem with your config or with the permission problem starting the service through IIS.

If you do not know how to start the service as a console application, see http://www.jacopretorius.net/2009/08/running-windows-service-inside-console.html

0
source share

All Articles