2

关于标题总结了我想要实现的目标,虽然现在我发布了一些代码,但我也想知道 LogFactory 是否在正确的位置。

谢谢你,斯蒂芬

public class ContactAppHost : AppHostBase
{
    //Tell Service Stack the name of your application and where to find your web services
    public ContactAppHost() : base("Contact Web Services", typeof (ContactService).Assembly)
    {
        // Built into the framework without the IOC
        LogManager.LogFactory = new NLogFactory();
    }

    public override void Configure(Funq.Container container)
    {
        //register any dependencies your services use, e.g:
        container.Register<ICacheClient>(new MemoryCacheClient());
    }
}


protected void Application_Start(object sender, EventArgs e)
{
    new ContactAppHost().Init();
}

protected void Application_Error(object sender, EventArgs e)
{

}
4

1 回答 1

1

ServiceStack 仅支持单个记录器的配置,理想情况下应在初始化 AppHost 之前指定,因此ILogServiceStack 中所有类的所有静态初始化器都使用配置的记录器,例如:

protected void Application_Start(object sender, EventArgs e)
{
    LogManager.LogFactory = new NLogFactory();
    new ContactAppHost().Init();
}
于 2013-04-04T17:41:26.123 回答