{"id":37040939,"url":"https://github.com/kmcclellan/property-logging","last_synced_at":"2026-01-14T04:50:46.645Z","repository":{"id":57887151,"uuid":"446918428","full_name":"kmcclellan/property-logging","owner":"kmcclellan","description":"An extension of Microsoft.Extensions.Logging to format logs using configurable named properties.","archived":false,"fork":false,"pushed_at":"2022-09-11T17:09:12.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T05:14:15.377Z","etag":null,"topics":["formatting","logging","properties"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/Logging.Properties/","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/kmcclellan.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}},"created_at":"2022-01-11T17:29:28.000Z","updated_at":"2022-02-08T14:17:17.000Z","dependencies_parsed_at":"2023-01-18T03:50:10.950Z","dependency_job_id":null,"html_url":"https://github.com/kmcclellan/property-logging","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kmcclellan/property-logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmcclellan%2Fproperty-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmcclellan%2Fproperty-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmcclellan%2Fproperty-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmcclellan%2Fproperty-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmcclellan","download_url":"https://codeload.github.com/kmcclellan/property-logging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmcclellan%2Fproperty-logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["formatting","logging","properties"],"created_at":"2026-01-14T04:50:46.026Z","updated_at":"2026-01-14T04:50:46.638Z","avatar_url":"https://github.com/kmcclellan.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Property Logging\n\nAn extension of `Microsoft.Extensions.Logging` to format logs using configurable named properties.\n\n### Features\n\n* Harness the power of configuration and/or options to specify what log information is handled by a custom logger.\n\n## Installation\n\nAdd the NuGet package to your project:\n\n    $ dotnet add package Logging.Properties\n\n## Usage\n\nThough .NET lets you structure logs in a variety of ways, it is common for different pieces of logged information to be handled similarly.\n\nProperty logging lets you implement loggers that write log entries as collections of named values:\n\n```c#\nclass MyPropertyLogger : PropertyLoggerProvider\n{\n    public MyPropertyLogger(IEnumerable\u003cILogPropertyMapper\u003cMyPropertyLogger\u003e\u003e mappers) : base(mappers)\n    {\n    }\n\n    protected override void Log(IEnumerable\u003cKeyValuePair\u003cstring, object\u003e\u003e properties)\n    {\n        Console.WriteLine(\"Logged properties: {0}\", string.Join(\" \", properties));\n    }\n}\n```\n\nThe mapping of log information to properties can be configured with `Microsoft.Extensions.Logging.ILoggingBuilder`:\n\n```c#\nservices.AddLogging(\n    builder =\u003e\n    {\n        // Add the standard property mappers (see below).\n        builder.AddProperties\u003cMyPropertyLogger\u003e();\n\n        // Configure \"lvl\" and \"msg\" as properties.\n        builder.Services.Configure\u003cEntryPropertyOptions\u003cMyPropertyLogger\u003e\u003e(\n            opts =\u003e\n            {\n                opts.Mappings[EntryField.LogLevel] = \"lvl\";\n                opts.Mappings[EntryField.Message] = \"msg\";\n            });\n\n        // Configure stack traces from nested exceptions.\n        builder.Services.Configure\u003cExceptionPropertyOptions\u003cMyPropertyLogger\u003e\u003e(\n            opts =\u003e\n            {\n                opts.Mappings[ExceptionField.StackTrace] = \"ex_stack\";\n                opts.IsRecursive = true;\n            });\n\n        // Configure properties from state (includes message template values).\n        builder.Services.Configure\u003cStatePropertyOptions\u003cMyPropertyLogger\u003e\u003e(\n            opts =\u003e\n            {\n                opts.Categories[\"*\"] = new()\n                {\n                    IncludeOthers = true,\n                    IncludeScopes = true,\n                };\n            });\n\n        // Alternatively, load provider options from configuration.\n        builder.AddConfiguration(config.GetSection(\"Logging\"));\n\n        // Finally, add your logger to the logger factory.\n        builder.Services.AddSingleton\u003cILoggerProvider, MyPropertyLogger\u003e();\n    });\n```\n\n### Standard mappers\n\n| Options Model | Configuration Section | Description |\n| -- | -- | -- |\n| [EntryPropertyOptions](Logging.Properties/Mapping/EntryPropertyOptions.cs) | `Properties:Entry` | Scalar mappings from the top-level log entry. |\n| [EventIdPropertyOptions](Logging.Properties/Mapping/EventIdPropertyOptions.cs) | `Properties:EventId` | Mappings from the logged event ID (`Id` and `Name`). |\n| [ExceptionPropertyOptions](Logging.Properties/Mapping/ExceptionPropertyOptions.cs) | `Properties:Exception` | Mappings from logged exceptions, including inner exceptions. |\n| [EnvironmentPropertyOptions](Logging.Properties/Mapping/EnvironmentPropertyOptions.cs) | `Properties:Environment` | Common mappings from `System.Environment`. |\n| [TimestampPropertyOptions](Logging.Properties/Mapping/TimestampPropertyOptions.cs) | `Properties:Timestamp` | Mapping from `DateTimeOffset.Now`. |\n| [StaticPropertyOptions](Logging.Properties/Mapping/StaticPropertyOptions.cs) | `Properties:Static` | Injection of static custom properties. |\n| [StatePropertyOptions](Logging.Properties/Mapping/StatePropertyOptions.cs) | `Properties:State` | Mappings from entry and scope state by category, including values logged with a message template. |\n\nRegister your own implementation of `ILogPropertyMapper\u003cTProvider\u003e` to map other kinds of data!\n\n### Example configuration\n\nAn example of ECS (Elasic Common Schema) mappings in `appsettings.json`:\n\n```json\n{\n  \"Logging\": {\n    \"MyApp.MyPropertyLogger\": {\n      \"LogLevel\": {\n        \"Default\": \"Debug\"\n      },\n      \"Properties\": {\n        \"Entry\": {\n          \"Mappings\": {\n            \"LogLevel\": \"log.level\",\n            \"Category\": \"log.logger\",\n            \"Message\": \"message\"\n          }\n        },\n        \"EventId\": {\n          \"Mappings\": {\n            \"Id\": \"event.code\",\n            \"Name\": \"event.action\"\n          }\n        },\n        \"Exception\": {\n          \"Mappings\": {\n            \"Type\": \"error.type\",\n            \"Message\": \"error.message\",\n            \"StackTrace\": \"error.stack_trace\"\n          },\n          \"IsRecursive\": true\n        },\n        \"State\": {\n          \"Categories\": {\n            \"System.Net.Http.HttpClient\": {\n              \"Mappings\": {\n                \"HttpMethod\": \"http.request.method\",\n                \"Uri\": \"url.original\",\n                \"StatusCode\": \"http.response.status_code\"\n              }\n            }\n          }\n        },\n        \"Timestamp\": {\n          \"Mapping\": \"@timestamp\"\n        },\n        \"Environment\": {\n          \"Mappings\": {\n            \"MachineName\": \"host.hostname\",\n            \"ProcessId\": \"process.pid\"\n          }\n        },\n        \"Static\": {\n          \"Values\": {\n            \"ecs.version\": \"1.12.1\"\n          }\n        }\n      }\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmcclellan%2Fproperty-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmcclellan%2Fproperty-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmcclellan%2Fproperty-logging/lists"}