{"id":13595463,"url":"https://github.com/datalust/nlog-targets-seq","last_synced_at":"2025-04-05T07:04:53.916Z","repository":{"id":17372373,"uuid":"81764791","full_name":"datalust/nlog-targets-seq","owner":"datalust","description":"An NLog target that writes events to Seq. Built for NLog 4.5+.","archived":false,"fork":false,"pushed_at":"2025-03-17T22:40:16.000Z","size":384,"stargazers_count":21,"open_issues_count":3,"forks_count":11,"subscribers_count":6,"default_branch":"dev","last_synced_at":"2025-03-29T06:06:45.183Z","etag":null,"topics":["nlog","nlog-target","seq"],"latest_commit_sha":null,"homepage":"https://getseq.net","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":null,"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-02-12T23:08:32.000Z","updated_at":"2025-03-17T22:40:20.000Z","dependencies_parsed_at":"2022-09-10T21:23:30.692Z","dependency_job_id":"69fb1897-14aa-43c3-87f5-bde8095268c6","html_url":"https://github.com/datalust/nlog-targets-seq","commit_stats":{"total_commits":72,"total_committers":7,"mean_commits":"10.285714285714286","dds":0.3055555555555556,"last_synced_commit":"e46d22146171dff7c341102a2b00a3bc89ddd30b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fnlog-targets-seq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fnlog-targets-seq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fnlog-targets-seq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fnlog-targets-seq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datalust","download_url":"https://codeload.github.com/datalust/nlog-targets-seq/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299831,"owners_count":20916190,"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":["nlog","nlog-target","seq"],"created_at":"2024-08-01T16:01:50.465Z","updated_at":"2025-04-05T07:04:53.898Z","avatar_url":"https://github.com/datalust.png","language":"C#","funding_links":[],"categories":["C#","C\\#"],"sub_categories":[],"readme":"# NLog.Targets.Seq [![NuGet Pre Release](https://img.shields.io/nuget/vpre/NLog.Targets.Seq.svg)](https://nuget.org/packages/NLog.Targets.Seq) [![Build status](https://ci.appveyor.com/api/projects/status/o22e6dq0mkftaggc?svg=true)](https://ci.appveyor.com/project/datalust/nlog-targets-seq)\n\nAn NLog target that writes events to [Seq](https://datalust.co/seq). The target takes full advantage of the structured logging support in **NLog 4.5** to provide hassle-free filtering, searching and analysis.\n\n### Getting started\n\nAfter installing NLog, install the _NLog.Targets.Seq_ package from NuGet:\n\n```\ndotnet add package NLog.Targets.Seq\n```\n\nThen, add the target and rules entries to your NLog configuration:\n\n```xml\n\u003cnlog\u003e\n  \u003cextensions\u003e\n    \u003cadd assembly=\"NLog.Targets.Seq\"/\u003e\n  \u003c/extensions\u003e\n  \u003ctargets\u003e\n    \u003ctarget name=\"seq\" xsi:type=\"BufferingWrapper\" bufferSize=\"1000\"\n            flushTimeout=\"2000\" slidingTimeout=\"false\"\u003e\n      \u003ctarget xsi:type=\"Seq\" serverUrl=\"http://localhost:5341\" apiKey=\"\" /\u003e\n    \u003c/target\u003e\n  \u003c/targets\u003e\n  \u003crules\u003e\n    \u003clogger name=\"*\" minlevel=\"Info\" writeTo=\"seq\" /\u003e\n  \u003c/rules\u003e\n\u003c/nlog\u003e\n```\n\nThe `BufferingWrapper` ensures that writes to Seq do not block the application.\n\nSet the `serverUrl` value to the address of your Seq server, and provide an API key if you have one set up.\n\nA complete sample application and _NLog.config_ file can be found [here in this repository](https://github.com/datalust/nlog-targets-seq/tree/dev/sample/Example).\n\n### Structured logging with NLog\n\nNLog 4.5 adds support for [message templates](https://messagetemplates.org), extended format strings that capture first-class properties along with the usual message text.\n\n```csharp\nvar logger = LogManager.GetCurrentClassLogger();\n\nfor (var i = 0; i \u003c 10; ++i)\n{\n    logger.Info(\"Hello, {Name}, on iteration {Counter}\", Environment.UserName, i);\n}\n```\n\nWhen the events logged in this snippet are rendered to a file or console, they'll appear just like regular formatted text. In Seq or another structured log data store, you'll see that the original `Name` and `Counter` values are preserved separately:\n\n![EventsInSeq](https://raw.githubusercontent.com/datalust/nlog-targets-seq/dev/asset/nlog-events-in-seq.png)\n\nThis makes filtering with expressions such as `Counter \u003e 8` or `Name like 'nb%'` trivial: no regular expressions or log parsing are needed to recover the original values.\n\nThe fully-rendered message is there too, so you can still search for text like `\"Hello, nblumhardt\"` and find the events you'd expect.\n\n### Attaching additional properties\n\nThe `target` declaration in _NLog.config_ can be expanded with additional properties:\n\n```xml\n  \u003ctarget xsi:type=\"Seq\" serverUrl=\"http://localhost:5341\" apiKey=\"\"\u003e\n    \u003cproperty name=\"ThreadId\" value=\"${threadid}\" as=\"number\" /\u003e\n    \u003cproperty name=\"MachineName\" value=\"${machinename}\" /\u003e\n    \u003cproperty name=\"Source\" value=\"${logger}\" /\u003e\n  \u003c/target\u003e\n```\n\nAny properties specified here will be attached to all outgoing events. You can see examples of `ThreadId` and `MachineName` in the screenshot above. The value can be any supported [layout renderer](https://github.com/NLog/NLog/wiki/Layout-Renderers).\n\n### Configuration in appsettings.json\n\nNLog.Extensions.Logging ver. 1.5.0 adds support for having [NLog configuration in appsettings.json](https://github.com/NLog/NLog.Extensions.Logging/wiki/NLog-configuration-with-appsettings.json)\n\n```json\n{\n  \"NLog\": {\n    \"throwConfigExceptions\": true,\n    \"extensions\": [\n      { \"assembly\": \"NLog.Targets.Seq\" }\n    ],\n    \"targets\": {\n      \"seq\": {\n        \"type\": \"BufferingWrapper\",\n        \"bufferSize\": 200,\n        \"flushTimeout\": 2000,\n        \"slidingTimeout\": false,\n        \"target\": {\n          \"type\": \"Seq\",\n          \"serverUrl\": \"http://localhost:5341\",\n          \"apiKey\": \"\",\n          \"properties\": [\n          {\n            \"name\": \"Source\",\n            \"value\": \"${Logger}\"\n          },\n          {\n            \"name\": \"ThreadId\",\n            \"value\": \"${ThreadId}\",\n            \"as\": \"number\"\n          },\n          {\n            \"name\": \"MachineName\",\n            \"value\": \"${MachineName}\"\n          }]\n        }\n      }\n    },\n    \"rules\": [\n    {\n      \"logger\": \"*\",\n      \"minLevel\": \"Info\",\n      \"writeTo\": \"seq\"\n    }]\n  }\n}\n```\n\n### Acknowledgements\n\nThe target is based on the earlier [_Seq.Client.NLog_ project](https://github.com/datalust/seq-client), and benefits from many contributions accepted into that repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fnlog-targets-seq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatalust%2Fnlog-targets-seq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fnlog-targets-seq/lists"}