jimmystridh / serilog-sinks-googlecloudlogging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serilog.Sinks.GoogleCloudLogging

Serilog sink that writes events to Google Cloud Platform Stackdriver Logging.

Getting started

Install package from Nuget:

   Install-Package Serilog.Sinks.GoogleCloudLogging

Configure logger:

var log = new LoggerConfiguration()
    .WriteTo.GoogleCloudLogging(new GoogleCloudLoggingSinkOptions("YOUR_PROJECT_ID"))
    .CreateLogger();

This library uses the Google-Cloud-Dotnet libraries which authenticate using the default service account on the machine. This is automatic on GCE VMs or you can use the gcloud SDK to authenticate yourself. The service account must have the Logs Writer permission to send logs.

Sink options:

Name Description Default
ProjectId Required - Google Cloud project ID where logs will be sent to.
ResourceType Resource type for logs. Must be one of the supported types listed in the cloud logging documentation. global
LogName Name of log under the resource type. Default
Labels Dictionary of string keys and values added to all logs. Individual log entries will automatically include Properties from Serilog events.
UseSourceContextAsLogName The log name for a log entry will be set to the SourceContext property if it's available. True

When using default options, logs will appear under these filter settings in the GCP Console:

About

License:MIT License


Languages

Language:C# 100.0%