1. 程式人生 > >Windows 服務中正確使用 log4net

Windows 服務中正確使用 log4net

其他 cati AI bsp eba onf rect net pan

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