I thought I would post an example of logging in ASP.NET 5 with Serilog using a Rolling Log File. You can certainly use other logging frameworks, like NLog or Log4Net, and they will work approximately the same. Microsoft.Framework.Logging is mainly an abstraction to use with logging and you can use whatever logging frameworks you want in your ASP.NET 5 and ASP.NET MVC 6 Web Applications.

Configure Logging in ASP.NET 5 Startup.cs

I installed the Serilog Nuget Package and then added a couple of dependencies to the ASP.NET 5's Project.json file.


I configured Serilog and logging in the Startup.cs file.

public class Startup {
    public Startup(IApplicationEnvironment appEnv) {
        Log.Logger = new LoggerConfiguration()

    public void ConfigureServices(IServiceCollection services) {

    public void Configure(IApplicationBuilder app,
                                ILoggerFactory loggerFactory) {


This is using the built-in Rolling Log File in Serilog. Serilog is configured in the Startup Class' Constructor and then added as a logging provider in the Configure Method using the AddSerilog Extension Method.

Logging in ASP.NET MVC 6 Controller

Logging using Serilog is now configured for this ASP.NET 5 / ASP.NET MVC 6 Web Application so we can use it in our controllers, services, middleware, etc. Here is an example of requesting a logger for the HomeController Class.

public class HomeController : Controller {
    private readonly ILogger _logger;

    public HomeController(ILogger<HomeController> logger) {
        _logger = logger;

    public IActionResult Index() {
        _logger.LogInformation("You are here!");
        return View();


This ASP.NET 5 Tutorial just scratches the surface of ASP.NET 5 Logging and Serilog. I hope you find it useful for understanding how to integrate Serilog into your ASP.NET 5 and ASP.NET MVC 6 Web Applications.