码迷,mamicode.com
首页 > Windows程序 > 详细

Windows 服务中正确使用 log4net

时间:2018-04-13 17:58:07      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:getdir   []   location   stat   sse   direct   name   style   cto   

public class Service1 : ServiceBase
{    
    // 进程的主入口点
    private static void Main()
    {
        string assemblyFilePath = Assembly.GetExecutingAssembly().Location;
        string assemblyDirPath = Path.GetDirectoryName(assemblyFilePath);
        string configFilePath = assemblyDirPath + "//log4net.config";
        DOMConfigurator.ConfigureAndWatch(new FileInfo(configFilePath));
        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] {new Service1()};
        ServiceBase.Run(ServicesToRun);
    }
    // 其他略
}

 

Windows 服务中正确使用 log4net

标签:getdir   []   location   stat   sse   direct   name   style   cto   

原文地址:https://www.cnblogs.com/highfly2012/p/8821564.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!