Created
February 1, 2016 10:22
-
-
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
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
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