{"id":16567317,"url":"https://github.com/chris-peterson/spiffy","last_synced_at":"2025-03-21T11:33:10.933Z","repository":{"id":632507,"uuid":"14413085","full_name":"chris-peterson/spiffy","owner":"chris-peterson","description":"A structured logging framework for .NET that supports log aggregation, e.g. Splunk","archived":false,"fork":false,"pushed_at":"2024-11-07T23:37:33.000Z","size":721,"stargazers_count":8,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T21:48:02.917Z","etag":null,"topics":["csharp","dotnet","dotnet-core","instrumentation","key-value-pairs","logging","metrics","monitoring","prometheus","splunk","splunk-enterprise","structured-logging"],"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/chris-peterson.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":"2013-11-15T02:28:39.000Z","updated_at":"2024-12-01T18:18:53.000Z","dependencies_parsed_at":"2023-07-05T15:02:08.955Z","dependency_job_id":"b00f8c9c-c56b-483a-8d17-c99498769edf","html_url":"https://github.com/chris-peterson/spiffy","commit_stats":{"total_commits":187,"total_committers":11,"mean_commits":17.0,"dds":0.6310160427807487,"last_synced_commit":"28016455113d84d1b4084bd244dc3e0f3c8c0c66"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fspiffy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fspiffy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fspiffy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chris-peterson%2Fspiffy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chris-peterson","download_url":"https://codeload.github.com/chris-peterson/spiffy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135891,"owners_count":20403796,"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":["csharp","dotnet","dotnet-core","instrumentation","key-value-pairs","logging","metrics","monitoring","prometheus","splunk","splunk-enterprise","structured-logging"],"created_at":"2024-10-11T21:06:16.365Z","updated_at":"2025-03-21T11:33:10.550Z","avatar_url":"https://github.com/chris-peterson.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\n\nA structured logging framework for .NET that supports log analysis (e.g. Splunk) and metrics gathering (e.g. Prometheus).\n\nBattle-tested in high-volume production environments for more than 10 years, handling over 1,000,0000,000,000 (1 trillion) requests.\n\n## Status\n\n[![build](https://github.com/chris-peterson/spiffy/actions/workflows/ci.yml/badge.svg)](https://github.com/chris-peterson/spiffy/actions/workflows/ci.yml)\n\nPackage | Latest Release |\n:-------- | :------------ |\n`Spiffy.Monitoring` | [![NuGet version](https://img.shields.io/nuget/dt/Spiffy.Monitoring.svg)](https://www.nuget.org/packages/spiffy.monitoring)\n`Spiffy.Monitoring.Aws` | [![NuGet version](https://img.shields.io/nuget/dt/Spiffy.Monitoring.Aws.svg)](https://www.nuget.org/packages/spiffy.monitoring.aws)\n`Spiffy.Monitoring.NLog` | [![NuGet version](https://img.shields.io/nuget/dt/Spiffy.Monitoring.NLog.svg)](https://www.nuget.org/packages/spiffy.monitoring.nlog)\n`Spiffy.Monitoring.Prometheus` | [![NuGet version](https://img.shields.io/nuget/dt/Spiffy.Monitoring.Prometheus.svg)](https://www.nuget.org/packages/spiffy.monitoring.prometheus)\n`Spiffy.Monitoring.Splunk` | [![NuGet version](https://img.shields.io/nuget/dt/Spiffy.Monitoring.Splunk.svg)](https://www.nuget.org/packages/spiffy.monitoring.splunk)\n\n## Setup\n\n`PM\u003e Install-Package Spiffy.Monitoring`\n\n### Built-In Logging Providers\n\n`Spiffy.Monitoring` includes \"built-in\" logging mechanisms (`Trace` and `Console`).\n\nThere is no default logging behavior, you must initialize provider(s) by calling `Spiffy.Monitoring.Configuration.Initialize`.\n\nUntil initialized, any published `EventContext` will not be observable, so it is recommended that initialization be as early as possible when your application is starting (i.e. in the entry point).\n\n**Example**\n\n```c#\n  Configuration.Initialize(spiffy =\u003e { spiffy.Providers.Console(); });\n```\n\n### Extended Providers\n\nFor extended functionality, you'll need to install a \"provider package\".\n\nNOTE: the provider package need only be installed for your application's entry point assembly, it need not be installed in library packages.\n\n#### NLog Provider\n\n`PM\u003e Install-Package Spiffy.Monitoring.NLog`\n\n**Example**\n\n```c#\n    static void Main() {\n        // this should be the first line of your application\n        Spiffy.Monitoring.Configuration.Initialize(spiffy =\u003e {\n            spiffy.Providers\n                .NLog(nlog =\u003e nlog.Targets(t =\u003e t.File()));\n        });\n    }\n```\n\n### Multiple Providers\n\nMultiple providers can be provied, for example, this application uses both `Console` (built-in), as well as `File` (NLog)\n\n**Example**\n\n```c#\n    Spiffy.Monitoring.Configuration.Initialize(spiffy =\u003e {\n        spiffy.Providers\n            .Console()\n            .NLog(nlog =\u003e nlog.Targets(t =\u003e t.File()));\n    });\n```\n\n## Log\n\n### Example Program\n\n```c#\n        // key-value-pairs set here appear in every event message\n        GlobalEventContext.Instance\n            .Set(\"Application\", \"MyApplication\");\n\n        using (var context = new EventContext()) {\n            context[\"Key\"] = \"Value\";\n\n            using (context.Time(\"LongRunning\")) {\n                DoSomethingLongRunning();\n            }\n\n            try {\n                DoSomethingDangerous();\n            }\n            catch (Exception ex) {\n                context.IncludeException(ex);\n            }\n        }\n```\n\n### Normal Entry\n\n\u003e [2014-06-13 00:05:17.634Z] Application=MyApplication **Level=Info** Component=Program Operation=Main TimeElapsed=1004.2 **Key=Value** TimeElapsed_LongRunning=1000.2\n\n### Exception Entry\n\n\u003e [2014-06-13 00:12:52.038Z] Application=MyApplication **Level=Error** Component=Program Operation=Main TimeElapsed=1027.0 Key=Value **ErrorReason=\"An exception has ocurred\"** **Exception_Type=ApplicationException Exception_Message=\"you were unlucky!\"** Exception_StackTrace=\"   at TestConsoleApp.Program.DoSomethingDangerous() in c:\\src\\git\\github\\chris-peterson\\Spiffy\\src\\Tests\\TestConsoleApp\\Program.cs:line 47\n   at TestConsoleApp.Program.Main() in c:\\src\\git\\github\\chris-peterson\\Spiffy\\src\\Tests\\TestConsoleApp\\Program.cs:line 29\" InnermostException_Type=NullReferenceException **InnermostException_Message=\"Object reference not set to an instance of an object.\"** Exception=\"See Exception_* and InnermostException_* for more details\" TimeElapsed_LongRunning=1000.0\n\n## Hosting Frameworks\n\n`Spiffy.Monitoring` is designed to be easy to use in any context.\n\nThe most basic usage is to instrument a specific method.\nThis can be achieved by \"newing up\" an `EventContext`.\nThis usage mode results in `Component` being set to the containing code's\nclass name, and `Operation` is set to the containing code's method name\n\nThere are times when you may want to instrument something that's not\na specific method.  One such example is an API -- in this context,\nyou might want to have 1 log event per request.  Consider setting\n`Component` to be the controller name, and `Operation`\nthe action name.  To acheive this, add middleware that calls\n`EventContext.Initialize` with the desired labels.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fspiffy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris-peterson%2Fspiffy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris-peterson%2Fspiffy/lists"}