SystemdHostBuilderExtensions.UseSystemd(IHostBuilder) Method

Definition

Configures the IHost lifetime to SystemdLifetime, provides notification messages for application started and stopping, and configures console logging to the systemd format.

C#
public static Microsoft.Extensions.Hosting.IHostBuilder UseSystemd(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder);

Parameters

hostBuilder
IHostBuilder

The IHostBuilder to configure.

Returns

The hostBuilder instance for chaining.

Remarks

This is context aware and will only activate if it detects the process is running as a systemd Service.

The systemd service file must be configured with Type=notify to enable notifications. See https://www.freedesktop.org/software/systemd/man/systemd.service.html.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Standard 2.1 (package-provided)