{"id":17030158,"url":"https://github.com/rob-blackbourn/jetblack.jsonconsolelogger","last_synced_at":"2026-04-10T15:56:03.681Z","repository":{"id":45147397,"uuid":"211844899","full_name":"rob-blackbourn/JetBlack.JsonConsoleLogger","owner":"rob-blackbourn","description":"A JSON console logger for .Net","archived":false,"fork":false,"pushed_at":"2022-12-08T14:53:02.000Z","size":27,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T00:20:03.864Z","etag":null,"topics":["csharp","dotnet","dotnet-standard","json","logging","structured-logging"],"latest_commit_sha":null,"homepage":null,"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/rob-blackbourn.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":"2019-09-30T11:32:29.000Z","updated_at":"2022-01-05T08:36:45.000Z","dependencies_parsed_at":"2023-01-25T05:20:13.453Z","dependency_job_id":null,"html_url":"https://github.com/rob-blackbourn/JetBlack.JsonConsoleLogger","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-blackbourn%2FJetBlack.JsonConsoleLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-blackbourn%2FJetBlack.JsonConsoleLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-blackbourn%2FJetBlack.JsonConsoleLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rob-blackbourn%2FJetBlack.JsonConsoleLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rob-blackbourn","download_url":"https://codeload.github.com/rob-blackbourn/JetBlack.JsonConsoleLogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245015734,"owners_count":20547458,"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-standard","json","logging","structured-logging"],"created_at":"2024-10-14T08:04:40.479Z","updated_at":"2025-12-30T23:43:57.905Z","avatar_url":"https://github.com/rob-blackbourn.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JetBlack.JsonConsolerLogger\n\n## Overview\n\nThis library provides a JSON console logger for the `Microsoft.Extensions.Logging` framework.\n\nIt was originally written for .Net services running in docker to provide structured logging for use with Elasticsearch.\n\n## Issues\n\nAt present the public interface provided by the Microsoft logging framework passes an important parameter as an internal class. Reflection is used in order to access this parameters. **If the underlying implementation is changed this logger will break.**\n\n## Installation\n\nThe package can be installed from [nuget](https://www.nuget.org/packages/JetBlack.JsonConsoleLogger/).\n\n## Usage\n\nThis is a modification of the logger in `Microsoft.Extensions.Logging.Console`, and can be used\nin exactly the same way. Please look at the [Microsoft documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.0) for more examples.\n\nHere is an example using a logger factory.\n\n```cs\nusing JetBlack.JsonConsoleLogger;\n\nnamespace Example\n{\n    class Program\n    {\n        var configuration = new ConfigurationBuilder()\n            .AddJsonFile(\"appsettings.json\", optional: false, reloadOnChange: true)\n            .Build();\n\n        var loggerFactory = LoggerFactory.Create(builder =\u003e\n        {\n            builder\n                .AddConfiguration(configuration.GetSection(\"Logging\"))\n                .AddJsonConsole();\n        });\n\n        var logger = loggerFactory.CreateLogger\u003cProgram\u003e();\n\n        logger.LogInformation(\"This is an {LevelName} message with a {Date}\", \"INFO\", DateTime.Now);\n\n        loggerFactory.Dispose();\n    }\n}\n```\n\nHere is a basic `appsettings.json` file.\n\n```json\n{\n  \"Logging\": {\n    \"LogLevel\": {\n      \"Default\": \"Trace\",\n      \"System\": \"Information\",\n      \"Microsoft\": \"Information\"\n    },\n    \"JsonConsoleLogger\": {\n      \"Timestamp\": \"utc\"\n    }\n  }\n}\n```\n\nThis would produce the following output.\n\n```bash\n{\"name\":\"Example.Program\",\"level\":\"information\",\"message\":\"This is an INFO message with a 09/30/2019 14:42:48\",\"parameters\":{\"LevelName\":\"INFO\",\"Date\":\"2019-09-30T14:42:48.2281211+01:00\"},\"timestamp\":\"2019-09-30T13:42:48.2402817\"}\n```\n\nEach message is newline terminated.\n\n## Configuration\n\n### Timestamps\n\nThe `Timestamp` option can be one of: `none`, `local`, `utc`.\n\n### Scopes\n\nTo include scope information set `IncludeScopes` to `true`.\n\n### Logging to standard error\n\nIf `LogToStdErr` is `true` the output will be sent to stderr, otherwise it will go to stdout.\n\n### Disabling exception logging\n\nIf `LogExceptions` is set to `false` the exception messages will not be output.\n\n### Flattening exceptions\n\nBy default inner exceptions will be output as a nested dictionary. Setting\n`flattenExceptions` to `true` changes this to a list with the outermost\nat the start of the list and the innermost at the end.\n\n### Tag names\n\nTags names can be overridden with a `names` dictionary.\n\nHere is an example:\n\n```json\n{\n  \"Logging\": {\n    \"LogLevel\": {\n      \"Default\": \"Trace\",\n      \"System\": \"Information\",\n      \"Microsoft\": \"Information\"\n    },\n    \"JsonConsole\":\n    {\n      \"Timestamp\": \"utc\",\n      \"logToStdErr\": true,\n      \"names\": {\n        \"name\": \"logName\",\n        \"level\": \"logLevel\",\n        \"message\": \"logMessage\",\n        \"parameters\": \"logParameters\",\n        \"exception\": \"logException\",\n        \"timestamp\": \"logTimestamp\",\n        \"exceptionMessage\": \"logExceptionMessage\",\n        \"innerException\": \"logInnerException\",\n        \"stackTrace\": \"logStackTrace\",\n        \"lineNumber\": \"logLineNumber\",\n        \"columnNumber\": \"logColumnNumber\",\n        \"fileName\": \"logFileName\",\n        \"method\": \"logMethod\",\n        \"trace\": \"trce\",\n        \"debug\": \"dbug\",\n        \"information\": \"info\",\n        \"Warning\": \"warn\",\n        \"error\": \"fail\", \n        \"critical\": \"crit\"\n      }\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob-blackbourn%2Fjetblack.jsonconsolelogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frob-blackbourn%2Fjetblack.jsonconsolelogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frob-blackbourn%2Fjetblack.jsonconsolelogger/lists"}