Created
May 4, 2022 19:50
-
-
Save iburlakov/345b1d4f64ad0ecc4fc2774dc78cde4f to your computer and use it in GitHub Desktop.
Use serilog in Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setup | |
var services = new ServiceCollection(); | |
services.AddLogging(logging => | |
{ | |
logging.AddSerilog(new LoggerConfiguration().ReadFrom.Configuration(Configuration).Enrich.FromLogContext().CreateLogger()); | |
}); | |
var serviceProvider = services.BuildServiceProvider(); | |
// using | |
var logger = _serviceProvider.GetRequiredService<ILogger<Function>>(); | |
logger.LogInformation("Hello World!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment