{"id":23626270,"url":"https://github.com/datalust/serilog-sinks-seq","last_synced_at":"2025-05-16T12:07:04.682Z","repository":{"id":27698108,"uuid":"31184849","full_name":"datalust/serilog-sinks-seq","owner":"datalust","description":"A Serilog sink that writes events to the Seq structured log server","archived":false,"fork":false,"pushed_at":"2024-12-20T23:14:41.000Z","size":874,"stargazers_count":246,"open_issues_count":3,"forks_count":52,"subscribers_count":14,"default_branch":"dev","last_synced_at":"2025-03-26T08:01:40.247Z","etag":null,"topics":["seq","serilog","serilog-sink"],"latest_commit_sha":null,"homepage":"https://datalust.co/seq","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datalust.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.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":"2015-02-22T22:55:09.000Z","updated_at":"2025-02-22T15:33:22.000Z","dependencies_parsed_at":"2023-02-19T02:31:39.704Z","dependency_job_id":"2008393e-fd01-4bee-ba95-cd0559266842","html_url":"https://github.com/datalust/serilog-sinks-seq","commit_stats":null,"previous_names":["serilog/serilog-sinks-seq"],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fserilog-sinks-seq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fserilog-sinks-seq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fserilog-sinks-seq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fserilog-sinks-seq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datalust","download_url":"https://codeload.github.com/datalust/serilog-sinks-seq/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246777832,"owners_count":20832032,"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":["seq","serilog","serilog-sink"],"created_at":"2024-12-27T22:52:43.514Z","updated_at":"2025-04-02T09:01:21.523Z","avatar_url":"https://github.com/datalust.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serilog.Sinks.Seq\u0026nbsp;[![Build status](https://github.com/datalust/serilog-sinks-seq/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/datalust/serilog-sinks-seq/actions)\u0026nbsp;[![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.Seq.svg)](https://nuget.org/packages/serilog.sinks.seq)\n\nA Serilog sink that writes events to the [Seq](https://datalust.co/seq) structured log server. Supports all modern .NET platforms.\n\n[\u003cimg alt=\"Package Logo\" src=\"https://datalust.co/images/seq-nuget.png\" width=\"128px\"\u003e](https://nuget.org/packages/serilog.sinks.seq)\n\n\u003e [!TIP]\n\u003e If you would like to see timing and dependency information in Seq, [SerilogTracing](https://github.com/serilog-tracing/serilog-tracing) is a Serilog extension that can send both logs and traces through this sink.\n\n\n### Getting started\n\nInstall _Serilog.Sinks.Seq_ into your .NET project:\n\n```powershell\n\u003e dotnet add package Serilog.Sinks.Seq\n```\n\nPoint the logger to Seq:\n\n```csharp\nLog.Logger = new LoggerConfiguration()\n    .WriteTo.Seq(\"http://localhost:5341\")\n    .CreateLogger();\n```\n\nAnd use the Serilog logging methods to associate named properties with log events:\n\n```csharp\nLog.Error(\"Failed to log on user {ContactId}\", contactId);\n```\n\nThen query log event properties like `ContactId` from the browser:\n\n![Query in Seq](https://raw.githubusercontent.com/serilog/serilog-sinks-seq/dev/assets/search-by-property.png)\n\nWhen the application shuts down, [ensure any buffered events are propertly flushed to Seq](https://merbla.com/2016/07/06/serilog-log-closeandflush/) by disposing the logger or calling `Log.CloseAndFlush()`:\n\n```csharp\nLog.CloseAndFlush();\n```\n\nThe sink can take advantage of Seq's [API keys](https://docs.datalust.co/docs/api-keys) to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the `apiKey` parameter of `WriteTo.Seq()`.\n\n### XML `\u003cappSettings\u003e` configuration\n\nTo adjust the Seq server URL at deployment time, it's often convenient to configure it using XML `\u003cappSettings\u003e`, in the `App.config` or `Web.config` file.\n\nBefore Serilog can be configured using XML, the [Serilog.Settings.AppSettings](https://nuget.org/packages/serilog.settings.appsettings) package must be installed and enabled using the `LoggerConfiguration`:\n\n```csharp\nLog.Logger = new LoggerConfiguration()\n    .ReadFrom.AppSettings()\n    .CreateLogger();\n```\n\nWhen XML is used for configuration, it's not necessary to include the `WriteTo.Seq()` method. It is important however that the _Serilog.Sinks.Seq.dll_ assembly is present alongside the app's binaries.\n\nThe settings typically included are:\n\n```xml\n\u003cconfiguration\u003e\n  \u003cappSettings\u003e\n    \u003cadd key=\"serilog:using:Seq\" value=\"Serilog.Sinks.Seq\" /\u003e\n    \u003cadd key=\"serilog:write-to:Seq.serverUrl\" value=\"http://localhost:5341\" /\u003e\n    \u003cadd key=\"serilog:write-to:Seq.apiKey\" value=\"[optional API key here]\" /\u003e\n```\n\nSerilog's XML configuration has several other capabilities that are described on the [Serilog wiki](https://github.com/serilog/serilog/wiki/AppSettings).\n\n### JSON `appsettings.json` configuration\n\nTo use the Seq sink with _Microsoft.Extensions.Configuration_, for example with ASP.NET Core or .NET Core, use the [Serilog.Settings.Configuration](https://github.com/serilog/serilog-settings-configuration) package. First install that package if you have not already done so:\n\n```powershell\ndotnet add package Serilog.Settings.Configuration\n```\n\nInstead of configuring the Seq sink directly in code, call `ReadFrom.Configuration()`:\n\n```csharp\nvar configuration = new ConfigurationBuilder()\n    .AddJsonFile(\"appsettings.json\")\n    .Build();\n\nvar logger = new LoggerConfiguration()\n    .ReadFrom.Configuration(configuration)\n    .CreateLogger();\n```\n\nIn your `appsettings.json` file, under the `Serilog` node, :\n\n```json\n{\n  \"Serilog\": {\n    \"WriteTo\": [\n      { \"Name\": \"Seq\", \"Args\": { \"serverUrl\": \"http://localhost:5341\" } }\n    ]\n  }\n}\n```\n\nSee the XML `\u003cappSettings\u003e` example above for a discussion of available `Args` options.\n\n\n### Dynamic log level control\n\nThe Seq sink can dynamically adjust the logging level up or down based on the level associated with an API key in Seq. To use this feature, create a `LoggingLevelSwitch` to control the `MinimumLevel`, and pass this in the `controlLevelSwitch` parameter of `WriteTo.Seq()`:\n\n```csharp\nvar levelSwitch = new LoggingLevelSwitch();\n\nLog.Logger = new LoggerConfiguration()\n    .MinimumLevel.ControlledBy(levelSwitch)\n    .WriteTo.Seq(\"http://localhost:5341\",\n                 apiKey: \"yeEZyL3SMcxEKUijBjN\",\n                 controlLevelSwitch: levelSwitch)\n    .CreateLogger();\n```\n\nThe equivalent configuration in XML (Serilog 2.6+) is:\n\n```xml\n\u003cconfiguration\u003e\n  \u003cappSettings\u003e\n    \u003c!-- declare the switch --\u003e\n    \u003cadd key=\"serilog:level-switch:$controlSwitch\" value=\"Information\" /\u003e\n    \u003c!-- use it to control the root logger --\u003e\n    \u003cadd key=\"serilog:minimum-level:controlled-by\" value=\"$controlSwitch\" /\u003e\n    \u003cadd key=\"serilog:using:Seq\" value=\"Serilog.Sinks.Seq\" /\u003e\n    \u003cadd key=\"serilog:write-to:Seq.serverUrl\" value=\"http://localhost:5341\" /\u003e\n    \u003cadd key=\"serilog:write-to:Seq.apiKey\" value=\"yeEZyL3SMcxEKUijBjN\" /\u003e\n    \u003c!-- give the sink access to the switch --\u003e\n    \u003cadd key=\"serilog:write-to:Seq.controlLevelSwitch\" value=\"$controlSwitch\" /\u003e\n```\n\nThe equivalent configuration in JSON is:\n\n```json\n{\n    \"Serilog\":\n    {\n        \"LevelSwitches\": { \"$controlSwitch\": \"Information\" },\n        \"MinimumLevel\": { \"ControlledBy\": \"$controlSwitch\" },\n        \"WriteTo\":\n        [{\n            \"Name\": \"Seq\",\n            \"Args\":\n            {\n                \"serverUrl\": \"http://localhost:5341\",\n                \"apiKey\": \"yeEZyL3SMcxEKUijBjN\",\n                \"controlLevelSwitch\": \"$controlSwitch\"\n            }\n        }]\n    }\n}\n```\n\nFor further information see the [Seq documentation](https://docs.datalust.co/docs/using-serilog#dynamic-level-control).\n\n### Troubleshooting\n\n\u003e Nothing showed up, what can I do?\n\nIf events don't appear in Seq after pressing the refresh button in the _filter bar_, either your application was unable to contact the Seq server, or else the Seq server rejected the log events for some reason.\n\n#### Server-side issues\n\nThe Seq server may reject incoming events if they're missing a required API key, if the payload is corrupted somehow, or if the log events are too large to accept.\n\nServer-side issues are diagnosed using the Seq _Ingestion Log_, which shows the details of any problems detected on the server side. The ingestion log is linked from the _Settings_ \u003e _Diagnostics_ page in the Seq user interface.\n\n#### Client-side issues\n\nIf there's no information in the ingestion log, the application was probably unable to reach the server because of network configuration or connectivity issues. These are reported to the application through Serilog's `SelfLog`.\n\nAdd the following line after the logger is configured to print any error information to the console:\n\n```csharp\nSerilog.Debugging.SelfLog.Enable(Console.Error);\n```\n\nIf the console is not available, you can pass a delegate into `SelfLog.Enable()` that will be called with each error message:\n\n```csharp\nSerilog.Debugging.SelfLog.Enable(message =\u003e {\n    // Do something with `message`\n});\n```\n\n#### Troubleshooting checklist\n\n * Check the Seq _Ingestion Log_, as described in the _Server-side issues_ section above.\n * Turn on the Serilog `SelfLog` as described above to check for connectivity problems and other issues on the client side.\n * Make sure your application calls `Log.CloseAndFlush()`, or disposes the root `Logger`, before it exits - otherwise, buffered events may be lost.\n * If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated \"hard\" if the close button in the title bar is used, so events buffered for sending to Seq may be lost if you use it.\n * [Raise an issue](https://github.com/serilog/serilog-sinks-seq/issues), ask for help on the [Seq support forum](https://docs.datalust.co/discuss) or email **support@datalust.co**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fserilog-sinks-seq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatalust%2Fserilog-sinks-seq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fserilog-sinks-seq/lists"}