Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace ServiceControl.Connector.MassTransit.Host.Commands;
using System.CommandLine;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.WindowsServices;
using Microsoft.Extensions.Logging;
using NServiceBus.Extensions.Logging;
using ServiceControl.Connector.MassTransit;
Expand Down Expand Up @@ -43,6 +44,9 @@ async Task<int> InternalHandler(RunMode runMode, bool isConsole, string[] connec
var builder = Host.CreateApplicationBuilder(connectorArgs);
builder.UseMassTransitConnector(runMode == RunMode.Setup);

// Registers WindowsServiceLifetime and EventLog logging when running as a Windows Service; no-op otherwise.
builder.Services.AddWindowsService();

if (isConsole)
{
builder.Logging.AddSimpleConsole(o =>
Expand All @@ -51,7 +55,7 @@ async Task<int> InternalHandler(RunMode runMode, bool isConsole, string[] connec
o.IncludeScopes = true;
});
}
else
else if (!WindowsServiceHelpers.IsWindowsService())
{
builder.Logging.AddSystemdConsole();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.14" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.14" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.14" />
<PackageReference Include="NServiceBus.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="System.CommandLine" Version="2.0.4" />
Expand Down
Loading