【发布时间】:2017-06-11 17:06:21
【问题描述】:
我正在使用以下代码自行安装 Windows 服务(此代码位于 Program.cs 中)。当我使用“servicename.exe --install”时,服务安装得很好,但是留下了一些安装日志。服务名称.InstallLog 和 InstallUtil.InstallLog。有没有办法完全禁用这些文件的日志记录?
if (Environment.UserInteractive)
{
string parameter = string.Concat(args);
switch (parameter)
{
case "--install":
ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
break;
case "--uninstall":
ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
break;
}
}
else
{
ServiceBase[] servicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(servicesToRun);
}
【问题讨论】:
标签: c# .net windows service windows-services