{"id":15409214,"url":"https://github.com/augustoproiete/prism-logging-serilog","last_synced_at":"2025-04-19T03:19:26.708Z","repository":{"id":38185771,"uuid":"164962565","full_name":"augustoproiete/prism-logging-serilog","owner":"augustoproiete","description":"Integrate Serilog with Prism in your WPF, UWP, or Xamarin Forms apps","archived":false,"fork":false,"pushed_at":"2023-08-11T21:45:29.000Z","size":416,"stargazers_count":43,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T06:43:12.981Z","etag":null,"topics":["hacktoberfest","logging","mvvm","prism","serilog","sinks","uap","uwp","wpf","xamarin","xaml"],"latest_commit_sha":null,"homepage":"","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/augustoproiete.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"augustoproiete","tidelift":"nuget/Prism.Logging.Serilog"}},"created_at":"2019-01-10T00:52:28.000Z","updated_at":"2025-01-20T21:35:33.000Z","dependencies_parsed_at":"2024-06-21T18:56:30.161Z","dependency_job_id":"60bbe26e-983e-4ab1-897c-7ef4973e1d18","html_url":"https://github.com/augustoproiete/prism-logging-serilog","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augustoproiete%2Fprism-logging-serilog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augustoproiete%2Fprism-logging-serilog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augustoproiete%2Fprism-logging-serilog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augustoproiete%2Fprism-logging-serilog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/augustoproiete","download_url":"https://codeload.github.com/augustoproiete/prism-logging-serilog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262379,"owners_count":21074295,"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":["hacktoberfest","logging","mvvm","prism","serilog","sinks","uap","uwp","wpf","xamarin","xaml"],"created_at":"2024-10-01T16:38:32.102Z","updated_at":"2025-04-19T03:19:26.657Z","avatar_url":"https://github.com/augustoproiete.png","language":"C#","funding_links":["https://github.com/sponsors/augustoproiete","https://tidelift.com/funding/github/nuget/Prism.Logging.Serilog"],"categories":[],"sub_categories":[],"readme":"| README.md |\n|:---|\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"assets/prism-nuget.png\" alt=\"Prism.Logging.Serilog\" width=\"100\" /\u003e\n\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003ePrism.Logging.Serilog\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n\nIntegrate [Serilog](https://serilog.net) with [Prism](https://prismlibrary.github.io) in your WPF, UWP, or Xamarin Forms apps.\n\n[![NuGet Version](http://img.shields.io/nuget/v/Prism.Logging.Serilog.svg?style=flat)](https://www.nuget.org/packages/Prism.Logging.Serilog) [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-serilog-orange.svg)](http://stackoverflow.com/questions/tagged/serilog) [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-prism-orange.svg)](http://stackoverflow.com/questions/tagged/prism)\n\nThis project provides a custom implementation of Prism's `ILoggerFacade`, that forwards messages to a Serilog logger, allowing developers to capture the logging events written in their _ViewModels_ and _Services_, in Serilog.\n\n\u003c/div\u003e\n\n## Give a Star! :star:\n\nIf you like or are using this project please give it a star. Thanks!\n\n## Getting started :rocket:\n\nTo use the `Prism.Logging.Serilog`, first install the [NuGet package](https://nuget.org/packages/prism.logging.serilog):\n\n```powershell\nInstall-Package Prism.Logging.Serilog\n```\n\nThen register Serilog with Prism's `IContainerRegistry` using `RegisterSerilog()`:\n\n```csharp\nprotected override void RegisterTypes(IContainerRegistry containerRegistry)\n{\n    // ...\n\n    containerRegistry.RegisterSerilog();\n}\n```\n\nLog events from Prism will be written to Serilog's `Log.Logger` by default. Alternatively, you can provide a specific instance of a `Serilog.ILogger`:\n\n```csharp\nprivate Serilog.ILogger _logger = Log.Logger;\n\nprotected override void RegisterTypes(IContainerRegistry containerRegistry)\n{\n    // ...\n\n    containerRegistry.RegisterSerilog(_logger);\n}\n```\n\n## Mapping of Prism Log messages to Serilog\n\n`Prism.Logging.Serilog` does The Right Thing™ :), as you'd expect:\n\n| Prism Category       | Serilog LogEventLevel       |\n| -------------------- | --------------------------- |\n| `Category.Debug`     | `LogEventLevel.Debug`       |\n| `Category.Info`      | `LogEventLevel.Information` |\n| `Category.Warn`      | `LogEventLevel.Warning`     |\n| `Category.Exception` | `LogEventLevel.Error`       |\n\n* The `Priority` set in log messages written via Prism gets forwarded to Serilog as a [context property](https://github.com/serilog/serilog/wiki/Writing-Log-Events#correlation) called `Priority`, with the value of the priority as a string. e.g. `\"High\"`.\n\n* Log messages forwarded to Serilog have the [`SourceContext`](https://github.com/serilog/serilog/wiki/Writing-Log-Events#source-contexts) property set to `Prism.Logging.Serilog.SerilogLoggerFacade`, allowing developers to use use [filters](https://github.com/serilog/serilog/wiki/Configuration-Basics#filters), [sub-loggers](https://github.com/serilog/serilog/wiki/Configuration-Basics#sub-loggers), and [minimum level overrides](https://github.com/serilog/serilog/wiki/AppSettings#adding-minimum-level-overrides).\n\n## Example\n\nIn the source code you can find a [demo project](sample) of a WPF application using Prism and Serilog. The initial setup looks something like this:\n\n```csharp\npublic partial class App\n{\n    protected override void OnStartup(StartupEventArgs e)\n    {\n        // Configure Serilog and the sinks at the startup of the app\n        Log.Logger = new LoggerConfiguration()\n            .MinimumLevel.Debug()\n            .WriteTo.File(path: \"MyApp.log\")\n            .CreateLogger();\n\n        base.OnStartup(e);\n    }\n\n    protected override void OnExit(ExitEventArgs e)\n    {\n        // Flush all Serilog sinks before the app closes\n        Log.CloseAndFlush();\n\n        base.OnExit(e);\n    }\n\n    protected override void RegisterTypes(IContainerRegistry containerRegistry)\n    {\n        // Register your ViewModels, Services, etc...\n        // ...\n\n        // Register Serilog with Prism\n        containerRegistry.RegisterSerilog();\n    }\n\n    protected override Window CreateShell()\n    {\n        return Container.Resolve\u003cMainWindow\u003e();\n    }\n}\n```\n\n## Release History\n\nClick on the [Releases](https://github.com/augustoproiete/prism-logging-serilog/releases) tab on GitHub.\n\n---\n\n_Copyright \u0026copy; 2019-2023 C. Augusto Proiete \u0026 Contributors - Provided under the [Apache License, Version 2.0](LICENSE)._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugustoproiete%2Fprism-logging-serilog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faugustoproiete%2Fprism-logging-serilog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugustoproiete%2Fprism-logging-serilog/lists"}