Sep 2017

Serilog is a great logging library for .NET that outputs structured logs to various sinks. Google Cloud Logging (previously known as Stackdriver) is a popular logging service that supports structured formats along with integrated error reporting, monitoring, forwarding, and archiving to cloud storage.

I created Serilog.Sinks.GoogleCloudLogging as a new sink to integrate with GCP using the native Logging API to send log events. All contextual data and properties from Serilog (and any added enrichment) are included and can be used to filter and group logs.

The sink uses GoogleCloudDotnet libraries which use the Default Application Credentials and automatically retrieve config for most GCP environments (App Engine, GCE, GKE, and Cloud Run) for easy deployment. See more details in the readme.

dotnet add package Serilog.Sinks.GoogleCloudLogging
var config = new GoogleCloudLoggingSinkOptions { ProjectId = "YOUR_PROJECT_ID" };
Log.Logger = new LoggerConfiguration().WriteTo.GoogleCloudLogging(config).CreateLogger();


No comments posted.