如何配置log4net的为WCFlog4net、WCF

2023-09-03 03:18:40 作者:我的人别碰别摸别掂记

在我的asp web表单的应用程序,我会做的log4net的初始化;

On my asp webforms app I would do the log4net initialization;

log4net.Config.XmlConfigurator.Configure();

在Global.asax中的的Application_Start,以便应用程序启动时它完成一次。

on global.asax on Application_Start so that it is done once when the application starts.

什么是log4net的配置为IIS托管WCF应用程序(询问具体在哪里放置这条线要使用的事件等)的正确方法,这样的log4net被初始化一次并没有不必要的初始化。

What is the right way of configuring log4net for IIS hosted WCF apps(asking specifically about where to place this line which event to use etc) so that log4net gets initialized once on and there is no unnecessary initializations.

推荐答案

同样的事情:的Application_Start 。毕竟这是一个ASP.NET应用程序。对于自托管服务,你可以配置 log4net的之前启动主机。

Same thing: Application_Start. After all it is an ASP.NET application. For self hosting services you could configure log4net just before starting the host.