デフォルトを削除できますEventLogInstaller
:
namespace MyService
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
// Remove the default Event Log Installer
EventLogInstaller DefaultInstaller = null;
foreach (Installer installer in serviceInstaller1.Installers)
{
if (installer is EventLogInstaller)
{
DefaultInstaller = (EventLogInstaller)installer;
break;
}
}
if (DefaultInstaller != null)
{
serviceInstaller1.Installers.Remove(DefaultInstaller);
}
}
}
}
または、Log
プロパティを変更することもできます。
foreach (Installer installer in serviceInstaller1.Installers)
{
if (installer is EventLogInstaller)
{
((EventLogInstaller)installer).Log = "MyLog";
break;
}
}
これで、イベントはMyLogに正常に記録され、サービスの開始/停止イベントは引き続きアプリケーションログに記録されます。
(ソース:serviceInstallerコンポーネントとそのデフォルトのEventLogInstaller)