{"id":21921260,"url":"https://github.com/manigandham/serilog-sinks-googlecloudlogging","last_synced_at":"2025-04-05T18:10:49.728Z","repository":{"id":24103493,"uuid":"100636841","full_name":"manigandham/serilog-sinks-googlecloudlogging","owner":"manigandham","description":"Serilog sink that writes events to Google Cloud Logging","archived":false,"fork":false,"pushed_at":"2024-08-06T15:10:42.000Z","size":175,"stargazers_count":43,"open_issues_count":8,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T17:09:40.893Z","etag":null,"topics":["gcp","google-cloud","google-cloud-platform","logging","serilog","serilog-sink","stackdriver"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manigandham.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-17T19:11:36.000Z","updated_at":"2024-12-04T10:01:19.000Z","dependencies_parsed_at":"2025-01-16T10:07:04.650Z","dependency_job_id":"f60b307b-0a6e-4600-a2d3-5e5c398bf499","html_url":"https://github.com/manigandham/serilog-sinks-googlecloudlogging","commit_stats":{"total_commits":174,"total_committers":14,"mean_commits":"12.428571428571429","dds":"0.13218390804597702","last_synced_commit":"4d6eb2f159d9203d892a589f99902013068c8d10"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manigandham%2Fserilog-sinks-googlecloudlogging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manigandham%2Fserilog-sinks-googlecloudlogging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manigandham%2Fserilog-sinks-googlecloudlogging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manigandham%2Fserilog-sinks-googlecloudlogging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manigandham","download_url":"https://codeload.github.com/manigandham/serilog-sinks-googlecloudlogging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378149,"owners_count":20929297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcp","google-cloud","google-cloud-platform","logging","serilog","serilog-sink","stackdriver"],"created_at":"2024-11-28T20:20:07.013Z","updated_at":"2025-04-05T18:10:49.709Z","avatar_url":"https://github.com/manigandham.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serilog.Sinks.GoogleCloudLogging\n\nSerilog sink that writes events to [Google Cloud Logging](https://cloud.google.com/logging/).\n\n-   Built for `net6.0`, `net5.0`, `netstandard2.0`\n-   [Release Notes](CHANGELOG.md)\n\n## Usage\n\n#### Install [package from Nuget](https://www.nuget.org/packages/Serilog.Sinks.GoogleCloudLogging/):\n\n```\ndotnet add package Serilog.Sinks.GoogleCloudLogging\n```\n\n#### Configure in code:\n\n```csharp\nvar config = new GoogleCloudLoggingSinkOptions { ProjectId = \"YOUR_PROJECT_ID\" };\nLog.Logger = new LoggerConfiguration().WriteTo.GoogleCloudLogging(config).CreateLogger();\n```\n\n#### Or configure with config file:\n\nThis requires the [`serilog-settings-configuration`](https://github.com/serilog/serilog-settings-configuration) package.\n\n```json\n\"Serilog\": {\n  \"Using\": [ \"Serilog.Sinks.GoogleCloudLogging\" ],\n  \"MinimumLevel\": \"Information\",\n  \"WriteTo\": [\n    {\n      \"Name\": \"GoogleCloudLogging\",\n      \"Args\": {\n        \"projectID\": \"PROJECT-ID-12345\",\n        \"restrictedToMinimumLevel\": \"Information\",\n        \"labels\": {\n          \"foo\": \"bar\"\n        }\n      }\n    }\n  ]\n}\n```\n\n```csharp\nvar config = new ConfigurationBuilder().AddJsonFile(\"appsettings.json\", optional: true, reloadOnChange: true).Build();\nLog.Logger = new LoggerConfiguration().ReadFrom.Configuration(config).CreateLogger();\n```\n\n-   Serilog example for .NET 6: https://blog.datalust.co/using-serilog-in-net-6/\n\n## GCP Integration\n\n### Authentication\n\nThis library uses the [Google Cloud .NET](https://cloud.google.com/dotnet/docs) client and [Application Default Credentials](https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application). The [`Logs Writer`](https://cloud.google.com/logging/docs/access-control) permission is required to send logs. There are several different ways to set credentials:\n\n-   GCE, GKE, Cloud Run, AppEngine and other managed services will have the Application Default Credentials set to the active service account for the resource and can be used without any additional configuration.\n-   Authenticate manually with the [gcloud SDK](https://cloud.google.com/sdk/) on a server to set the Application Default Credentials.\n-   Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to specify the path to your JSON credentials file.\n-   Set the `GoogleCredentialJson` config option to pass in a JSON string (the contents of your JSON credentials file).\n\n### Log Output\n\n-   Serilog is designed for **[structured logging](https://github.com/serilog/serilog/wiki/Structured-Data)** which is fully supported by Google Cloud. Logs are sent as a JSON object (`JsonPayload` in the protobuf API) with labels, properties, metadata and any other data like stack traces automatically attached.\n-   **Numeric values in labels and properties will be converted to `double` during serialization** because that is the only numeric type supported by JSON. Large integers and floating-point values will lose precision. If you want the exact value preserved then log it as a string instead.\n-   GCP Error Reporting is separate from Cloud Logging and **will automatically capture error messages only if they have an `Exception` attached**. It is _not_ based on log severity level.\n-   View logs in the GCP Logs Explorer: https://console.cloud.google.com/logs/viewer\n\n## Sink Options\n\n| Option                    | Description                                                                                                                                                                                                             |\n| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| 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.                                                                         |\n| ResourceType              | Resource type for logs. Automatically identified if running in GCP or will default to \"global\". See [Monitored Resources and Services](https://cloud.google.com/logging/docs/api/v2/resource-list) for supported types. |\n| LogName                   | Name of the log. Default is \"Default\", or will use `SourceContext` is setting is enabled.                                                                                                                               |\n| Labels                    | Optional `Dictionary\u003cstring, string\u003e` labels added to all log entries.                                                                                                                                                  |\n| ResourceLabels            | Optional `Dictionary\u003cstring, string\u003e` labels added to all log entries, for the resource type. See [Monitored Resources and Services](https://cloud.google.com/logging/docs/api/v2/resource-list) for recognized labels. |\n| ServiceName               | Name of the service added as metadata to log entries. Required for logged exceptions to be forwarded to StackDriver Error Reporting.                                                                                    |\n| ServiceVersion            | Version of the service added as metadata to log entries. Required for logged exceptions to be forwarded to StackDriver Error Reporting.                                                                                 |\n| UseSourceContextAsLogName | The log name for a log entry will be set to the [SourceContext](https://github.com/serilog/serilog/wiki/Writing-Log-Events#source-contexts) property if available. Default is `true`.                                   |\n| UseLogCorrelation         | Integrate logs with [Cloud Trace](https://cloud.google.com/trace) by setting `Trace`, `SpanId`, `TraceSampled` properties if available. Default is `true`.                                                              |\n| GoogleCredentialJson      | JSON string to override [Application Default Credentials](https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application) (contents of your credential file).                        |\n\n### Log Level Mapping\n\nThis table shows the mapping from Serilog [`LogLevel`](https://github.com/serilog/serilog/wiki/Configuration-Basics#minimum-level) to Google Cloud Logging [`LogSeverity`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity)\n\n| Serilog     | Cloud Logging |\n| ----------- | ------------- |\n| Verbose     | Debug         |\n| Debug       | Debug         |\n| Information | Info          |\n| Warning     | Warning       |\n| Error       | Error         |\n| Fatal       | Critical      |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanigandham%2Fserilog-sinks-googlecloudlogging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanigandham%2Fserilog-sinks-googlecloudlogging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanigandham%2Fserilog-sinks-googlecloudlogging/lists"}