Added the logs setp in program.cs
This commit is contained in:
parent
5deb97d73b
commit
30d614fa11
@ -23,9 +23,21 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
#region ======================= Service Configuration (Dependency Injection) =======================
|
#region ======================= Service Configuration (Dependency Injection) =======================
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
|
|
||||||
|
// Add Serilog Configuration
|
||||||
|
string? mongoConn = builder.Configuration["MongoDB:SerilogDatabaseUrl"];
|
||||||
|
string timeString = "00:00:30";
|
||||||
|
TimeSpan.TryParse(timeString, out TimeSpan timeSpan);
|
||||||
|
|
||||||
builder.Host.UseSerilog((context, config) =>
|
builder.Host.UseSerilog((context, config) =>
|
||||||
{
|
{
|
||||||
config.ReadFrom.Configuration(context.Configuration);
|
config.ReadFrom.Configuration(context.Configuration)
|
||||||
|
.WriteTo.MongoDB(
|
||||||
|
databaseUrl: mongoConn ?? string.Empty,
|
||||||
|
collectionName: "api-logs",
|
||||||
|
batchPostingLimit: 100,
|
||||||
|
period: timeSpan
|
||||||
|
);
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user