A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/manigandham/serilog-sinks-googlecloudlogging below:

manigandham/serilog-sinks-googlecloudlogging: Serilog sink that writes events to Google Cloud Logging

Serilog.Sinks.GoogleCloudLogging

Serilog sink that writes events to Google Cloud Logging.

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

This requires the serilog-settings-configuration package.

"Serilog": {
  "Using": [ "Serilog.Sinks.GoogleCloudLogging" ],
  "MinimumLevel": "Information",
  "WriteTo": [
    {
      "Name": "GoogleCloudLogging",
      "Args": {
        "projectID": "PROJECT-ID-12345",
        "restrictedToMinimumLevel": "Information",
        "labels": {
          "foo": "bar"
        }
      }
    }
  ]
}
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(config).CreateLogger();

This library uses the Google Cloud .NET client and Application Default Credentials. The Logs Writer permission is required to send logs. There are several different ways to set credentials:

Option Description ProjectId ID (not name) of GCP project where logs will be sent. Optional if running in GCP. Required if running elsewhere or to override the destination. ResourceType Resource type for logs. Automatically identified if running in GCP or will default to "global". See Monitored Resources and Services for supported types. LogName Name of the log. Default is "Default", or will use SourceContext is setting is enabled. Labels Optional Dictionary<string, string> labels added to all log entries. ResourceLabels Optional Dictionary<string, string> labels added to all log entries, for the resource type. See Monitored Resources and Services for recognized labels. ServiceName Name of the service added as metadata to log entries. Required for logged exceptions to be forwarded to StackDriver Error Reporting. ServiceVersion Version of the service added as metadata to log entries. Required for logged exceptions to be forwarded to StackDriver Error Reporting. UseSourceContextAsLogName The log name for a log entry will be set to the SourceContext property if available. Default is true. UseLogCorrelation Integrate logs with Cloud Trace by setting Trace, SpanId, TraceSampled properties if available. Default is true. GoogleCredentialJson JSON string to override Application Default Credentials (contents of your credential file).

This table shows the mapping from Serilog LogLevel to Google Cloud Logging LogSeverity

Serilog Cloud Logging Verbose Debug Debug Debug Information Info Warning Warning Error Error Fatal Critical

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4