Skip to content

Instantly share code, notes, and snippets.

@ddikman
Created February 1, 2016 10:22
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 ddikman/863e5d5ebbca590a68bf to your computer and use it in GitHub Desktop.
Save ddikman/863e5d5ebbca590a68bf to your computer and use it in GitHub Desktop.
Example of how to read serilog configuration and add into Asp Net 5
public class Startup
{
public Startup(IHostingEnvironment env)
{
string configFile = $"config.{env.EnvironmentName}.json".ToLower();
var configBuilder = new ConfigurationBuilder().AddJsonFile(configFile);
Configuration = configBuilder.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Settings(new LoggerSettings(Configuration.GetSection("Logging")))
.CreateLogger();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
// ....
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment