Skip to content

Instantly share code, notes, and snippets.

@iburlakov
Created May 4, 2022 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iburlakov/345b1d4f64ad0ecc4fc2774dc78cde4f to your computer and use it in GitHub Desktop.
Save iburlakov/345b1d4f64ad0ecc4fc2774dc78cde4f to your computer and use it in GitHub Desktop.
Use serilog in Lambda
// 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