首页 > Windows开发 > 详细

Windows 服务中正确使用 log4net

时间:2018-04-13 17:10:26      阅读:246      评论:0      收藏:0      [点我收藏+]
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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!