Skip to content

serilog-contrib/serilog-sinks-msbuild

Repository files navigation

A Serilog sink for MSBuild

License: Apache License 2.0 Nuget package: Serilog.Sinks.MSBuild

How to use

using Microsoft.Build.Utilities;
using Serilog;

public class MyTask: Task {

    public override bool Execute() {
        using (ILogger _logger = new LoggerConfiguration().WriteTo.MSBuild(this).CreateLogger()) {
            _logger.Information("Hello from my custom Serilog-powered task");
            // [...]
            return true;
        };
    }
}

Important properties

Some Serilog properties carry meaningful information for MSBuild, like message code, file and line and column numbers.

They are covered in Serilog.Sinks.MSBuild.MSBuildMessages.

Maintainer(s)