-
Notifications
You must be signed in to change notification settings - Fork 43
Install
Matteo Gregoricchio edited this page Oct 10, 2024
·
3 revisions
Install the Serilog.UI NuGet package:
# using dotnet cli
dotnet add package Serilog.UI
# using package manager:
Install-Package Serilog.UI
Install one of the available providers, based upon your sink:
Provider | install: dotnet | install: pkg manager |
---|---|---|
Serilog.UI.MsSqlServerProvider [NuGet] | dotnet add package Serilog.UI.MsSqlServerProvider |
Install-Package Serilog.UI.MsSqlServerProvider |
Serilog.UI.MySqlProvider [NuGet] | dotnet add package Serilog.UI.MySqlProvider |
Install-Package Serilog.UI.MySqlProvider |
Serilog.UI.PostgreSqlProvider [NuGet] | dotnet add package Serilog.UI.PostgreSqlProvider |
Install-Package Serilog.UI.PostgreSqlProvider |
Serilog.UI.MongoDbProvider [NuGet] | dotnet add package Serilog.UI.MongoDbProvider |
Install-Package Serilog.UI.MongoDbProvider |
Serilog.UI.ElasticSearchProvider [NuGet] | dotnet add package Serilog.UI.ElasticSearchProvider |
Install-Package Serilog.UI.ElasticSearcProvider |
Serilog.UI.RavenDbProvider [NuGet] | dotnet add package Serilog.UI.RavenDbProvider |
Install-Package Serilog.UI.RavenDbProvider |
Serilog.UI.SQLiteProvider [NuGet] | dotnet add package Serilog.UI.SQLiteProvider |
Install-Package Serilog.UI.SQLiteProvider |
Add AddSerilogUi()
to IServiceCollection
in your Startup.ConfigureServices
method:
public void ConfigureServices(IServiceCollection services)
{
// Register the serilog UI services
services.AddSerilogUi(options =>
// each provider exposes extension methods to configure.
// note: you can register different providers at the same time.
// example:
options.UseSqlServer(/* configuration... */)
options.UseMongoDb(/* configuration... */)
);
}
You can register different providers at the same time. If you want to register more than one log database, you can register them by calling multiple times the Use[Provider] extensions:
public void ConfigureServices(IServiceCollection services)
{
services.AddSerilogUi(options => options
.UseSqlServer(/* configuration... */)
.UseSqlServer(/* configuration... */)
);
}
In the Startup.Configure
method or on the WebApplication builder, enable the Serilog UI middleware to serve the log UI page.
Note: the UseSerilogUi
call must be placed after any Authentication and Authorization middleware, otherwise the authentication may not work.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
(...)
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
// Enable middleware to serve log-ui (HTML, JS, CSS, etc.).
app.UseSerilogUi();
(...)
}