Log4Net in WCF not working

前端 未结 5 1063
情深已故
情深已故 2020-12-03 22:40

Hi I am trying to use Log4Net in WCF IIS hosted service, but it doesn\'t log any data. Has anyone achieved logging in WCF service using Log4Net?

5条回答
  •  天命终不由人
    2020-12-03 23:29

    Another thing to be careful of is when you have a custom WCF ServiceHostFactory defined in a separate assembly to your Wcf endpoint (eg to keep DRY) then the assembly where the factory is defined is the the "root" assembly from the point of view of log4net and the XmlConfigurator attribute needs to be declared in that assembly.

    This FAQ http://logging.apache.org/log4net/release/faq.html#trouble-webapp-stops-logging and linked comments explain that log4net wants to initialize as soon as possible

提交回复
热议问题