Search code examples
c#wcfiislog4net

Log4Net out of a IIS Hosted WCF Service


Good day folks

I must have read about 20 different articles/approaches about how to implement log4net in ASP.NET 1.0 / 2.0 and various other application types.

Link #1

Link #2

Link #3

Well, above articles are all ok, i did try/follow all of them, but i never got a log file..

What i have: IIS Hosted WCF Service.

What i want:

Logging using log4net - well, first i wanted to use Tracing (like Trace.Write in System.Diagnostics) then the Microsoft Enterprise Library and finally i'm stuck trying to figure out how to setup/configure log4net for my logging needs.

My question:

How to get log4net writing a logfile? i mean:

  • is it a security problem? do i really need to procmon this?
  • is the problem to write to a log file (security)?
  • is the problem that the configuration file cannot be read?

i tried:

  • Specifying the log4net.config using

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

  • Specifying the configuration in web.config after the block. When i did that i wasn't able to run the Web Application anymore (IIS reports corrupt web.config).

Help in this issue is really appreciated!

Christian


Solution

  • Ok, my fault. It was the declaration when ConfigFileExtension is declared, log4net searches for .dll. in the web root. Just changed that to ConfigFile and it's working like a charm. my careless mistake...!

    Christian