{"id":18937477,"url":"https://github.com/verifytests/verify.microsoftlogging","last_synced_at":"2026-04-11T03:39:12.896Z","repository":{"id":42575960,"uuid":"412396220","full_name":"VerifyTests/Verify.MicrosoftLogging","owner":"VerifyTests","description":"Extends Verify to allow verification of MicrosoftLogging bits.","archived":false,"fork":false,"pushed_at":"2025-04-14T11:24:09.000Z","size":441,"stargazers_count":7,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T12:29:46.048Z","etag":null,"topics":[],"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/VerifyTests.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":"code_of_conduct.md","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},"funding":{"github":"VerifyTests"}},"created_at":"2021-10-01T08:56:27.000Z","updated_at":"2025-04-14T11:24:13.000Z","dependencies_parsed_at":"2023-12-22T20:59:33.784Z","dependency_job_id":"d97a0d77-1aec-4b08-acc7-37a08a39f075","html_url":"https://github.com/VerifyTests/Verify.MicrosoftLogging","commit_stats":{"total_commits":152,"total_committers":3,"mean_commits":"50.666666666666664","dds":"0.052631578947368474","last_synced_commit":"7e43e429010927072db87b94b60b824a02cbf292"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.MicrosoftLogging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.MicrosoftLogging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.MicrosoftLogging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VerifyTests%2FVerify.MicrosoftLogging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VerifyTests","download_url":"https://codeload.github.com/VerifyTests/Verify.MicrosoftLogging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249129253,"owners_count":21217314,"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":[],"created_at":"2024-11-08T12:11:19.545Z","updated_at":"2026-04-11T03:39:12.885Z","avatar_url":"https://github.com/VerifyTests.png","language":"C#","funding_links":["https://github.com/sponsors/VerifyTests"],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"/src/icon.png\" height=\"30px\"\u003e Verify.MicrosoftLogging\n\n[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true\u0026label=)](https://github.com/orgs/VerifyTests/discussions)\n[![Build status](https://img.shields.io/appveyor/build/SimonCropp/verify-microsoftlogging)](https://ci.appveyor.com/project/SimonCropp/verify-microsoftlogging)\n[![NuGet Status](https://img.shields.io/nuget/v/Verify.MicrosoftLogging.svg)](https://www.nuget.org/packages/Verify.MicrosoftLogging/)\n\nExtends [Verify](https://github.com/VerifyTests/Verify) to allow verification of MicrosoftLogging bits.\u003c!-- singleLineInclude: intro. path: /docs/intro.include.md --\u003e\n\n**See [Milestones](../../milestones?state=closed) for release notes.**\n\n\n## Sponsors\n\n\n### Entity Framework Extensions\u003c!-- include: sponsors. path: /docs/sponsors.include.md --\u003e\n\n[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp\u0026utm_medium=Verify.MicrosoftLogging) is a major sponsor and is proud to contribute to the development this project.\n\n[![Entity Framework Extensions](https://raw.githubusercontent.com/VerifyTests/Verify.MicrosoftLogging/refs/heads/main/docs/zzz.png)](https://entityframework-extensions.net/?utm_source=simoncropp\u0026utm_medium=Verify.MicrosoftLogging)\n\n### Developed using JetBrains IDEs\n\n[![JetBrains logo.](https://raw.githubusercontent.com/VerifyTests/Verify.MicrosoftLogging/main/docs/jetbrains.png)](https://jb.gg/OpenSourceSupport)\u003c!-- endInclude --\u003e\n\n\n## NuGet\n\n * https://nuget.org/packages/Verify.MicrosoftLogging\n\n\n## Usage\n\n\u003c!-- snippet: Enable --\u003e\n\u003ca id='snippet-Enable'\u003e\u003c/a\u003e\n```cs\n[ModuleInitializer]\npublic static void Initialize() =\u003e\n    VerifyMicrosoftLogging.Initialize();\n```\n\u003csup\u003e\u003ca href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Enable' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\nLogging Recording allows, when a method is being tested, for any [logging](https://docs.microsoft.com/en-us/dotnet/core/extensions/logging) made as part of that method call to be recorded and verified.\n\nCall `LoggerRecording.Start();` to get an instance of the `LoggerProvider`. `LoggerProvider` implements both `ILogger` and `ILoggerProvider`.\n\nThen pass in the `LoggerProvider` instance to a class/method that write log entries:\n\n\u003c!-- snippet: LoggerRecording --\u003e\n\u003ca id='snippet-LoggerRecording'\u003e\u003c/a\u003e\n```cs\n[Fact]\npublic Task Logging()\n{\n    Recording.Start();\n    var logger = new RecordingLogger();\n    var target = new ClassThatUsesLogging(logger);\n\n    var result = target.Method();\n\n    return Verify(result);\n}\n\nclass ClassThatUsesLogging(ILogger logger)\n{\n    public string Method()\n    {\n        logger.LogWarning(\"The log entry\");\n        using (logger.BeginScope(\"The scope\"))\n        {\n            logger.LogWarning(\"Entry in scope\");\n        }\n\n        return \"result\";\n    }\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L49-L77' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-LoggerRecording' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nResults in:\n\n\u003c!-- snippet: Tests.Logging.verified.txt --\u003e\n\u003ca id='snippet-Tests.Logging.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  target: result,\n  log: [\n    {\n      Warning: The log entry\n    },\n    {\n      Message: StartScope,\n      State: The scope\n    },\n    {\n      Warning: Entry in scope\n    },\n    {\n      Message: EndScope\n    }\n  ]\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.Logging.verified.txt#L1-L18' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Tests.Logging.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n### Typed\n\nA common pattern is to use a type logger (`Logger\u003cT\u003e`). `LoggerProvider` provides a builder method `CreateLogger\u003cT\u003e` to construct a `Logger\u003cT\u003e`:\n\n\u003c!-- snippet: LoggerRecordingTyped --\u003e\n\u003ca id='snippet-LoggerRecordingTyped'\u003e\u003c/a\u003e\n```cs\n[Fact]\npublic Task LoggingTyped()\n{\n    Recording.Start();\n    var logger = RecordingProvider.CreateLogger\u003cClassThatUsesTypedLogging\u003e();\n    var target = new ClassThatUsesTypedLogging(logger);\n\n    var result = target.Method();\n\n    return Verify(result);\n}\n\nclass ClassThatUsesTypedLogging(ILogger\u003cClassThatUsesTypedLogging\u003e logger)\n{\n    public string Method()\n    {\n        logger.LogWarning(\"The log entry\");\n        return \"result\";\n    }\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.cs#L5-L28' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-LoggerRecordingTyped' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\nResults in:\n\n\u003c!-- snippet: Tests.LoggingTyped.verified.txt --\u003e\n\u003ca id='snippet-Tests.LoggingTyped.verified.txt'\u003e\u003c/a\u003e\n```txt\n{\n  target: result,\n  log: {\n    Warning: The log entry,\n    Category: ClassThatUsesTypedLogging\n  }\n}\n```\n\u003csup\u003e\u003ca href='/src/Tests/Tests.LoggingTyped.verified.txt#L1-L7' title='Snippet source file'\u003esnippet source\u003c/a\u003e | \u003ca href='#snippet-Tests.LoggingTyped.verified.txt' title='Start of snippet'\u003eanchor\u003c/a\u003e\u003c/sup\u003e\n\u003c!-- endSnippet --\u003e\n\n\n## Icon\n\n[Log](https://thenounproject.com/term/log/324064/) designed by [Ben Davis](https://thenounproject.com/smashicons/) from [The Noun Project](https://thenounproject.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.microsoftlogging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fverifytests%2Fverify.microsoftlogging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fverifytests%2Fverify.microsoftlogging/lists"}