Skip to content

Commit

Permalink
Add custom logging configuration with timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
GodVenn committed Oct 17, 2022
1 parent 50063ee commit 808588a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/api/Configurations/ConfigurationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,20 @@ public static void AddAzureEnvironmentVariables(this WebApplicationBuilder build
Console.WriteLine("'AZURE_TENANT_ID' set to " + tenantId);
}
}

/// <summary>
/// Configures the logger used by the application
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static void ConfigureLogger(this WebApplicationBuilder builder)
{
builder.Logging.AddSimpleConsole(options =>
{
options.IncludeScopes = true;
options.TimestampFormat = "yyyy-MM-dd HH:mm:ss - ";
options.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Enabled;
});
}
}
}
1 change: 1 addition & 0 deletions backend/api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var builder = WebApplication.CreateBuilder(args);

builder.AddAzureEnvironmentVariables();
builder.ConfigureLogger();

builder.Services.ConfigureDatabase(builder.Configuration);

Expand Down

0 comments on commit 808588a

Please sign in to comment.