Skip to content

Commit d3aa8a5

Browse files
Avoid adding windows event logging when running as a windows service (#5257)
Co-authored-by: Timothy Coleman <[email protected]>
1 parent c1d4b8d commit d3aa8a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/KurrentDB/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ async Task Run(ClusterVNodeHostedService hostedService) {
216216

217217
var builder = WebApplication.CreateBuilder(applicationOptions);
218218
builder.Configuration.AddConfiguration(configuration);
219+
// AddWindowsService adds EventLog logging, which we remove afterwards.
220+
builder.Services.AddWindowsService();
219221
builder.Logging.ClearProviders().AddSerilog();
220222
builder.Services.Configure<KestrelServerOptions>(configuration.GetSection("Kestrel"));
221223
builder.Services.Configure<HostOptions>(x => {
@@ -256,7 +258,6 @@ async Task Run(ClusterVNodeHostedService hostedService) {
256258
builder.Services.AddScoped<IdentityRedirectManager>();
257259
builder.Services.AddSingleton(monitoringService);
258260
builder.Services.AddSingleton(metricsObserver);
259-
builder.Services.AddWindowsService();
260261
Log.Information("Environment Name: {0}", builder.Environment.EnvironmentName);
261262
Log.Information("ContentRoot Path: {0}", builder.Environment.ContentRootPath);
262263

0 commit comments

Comments
 (0)