├── .config └── dotnet-tools.json ├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── dependabot-cake.yml ├── .gitignore ├── CHANGES.md ├── CODEOWNERS ├── LICENSE ├── README.md ├── SECURITY.md ├── assets ├── prism-nuget.png └── prism.snk ├── global.json ├── nuget.config ├── prism-logging-serilog.sln ├── prism-logging-serilog.sln.DotSettings ├── sample ├── net45 │ └── PrismSerilogWpfDemoNet45 │ │ ├── App.config │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── PrismSerilogWpfDemoNet45.csproj │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ │ ├── ViewModels │ │ └── MainWindowViewModel.cs │ │ ├── Views │ │ ├── MainWindow.xaml │ │ └── MainWindow.xaml.cs │ │ └── packages.config ├── netcoreapp3.0 │ └── PrismSerilogWpfDemoNetCoreApp30 │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── PrismSerilogWpfDemoNetCoreApp30.csproj │ │ ├── ViewModels │ │ └── MainWindowViewModel.cs │ │ └── Views │ │ ├── MainWindow.xaml │ │ └── MainWindow.xaml.cs └── netstandard2.0 │ └── PrismSerilogXamarinDemoNetStandard20 │ ├── PrismSerilogXamarinDemoNetStandard20.Android │ ├── AndroidInitializer.cs │ ├── Assets │ │ └── AboutAssets.txt │ ├── MainActivity.cs │ ├── PrismSerilogXamarinDemoNetStandard20.Android.csproj │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ └── Resources │ │ ├── AboutResources.txt │ │ ├── layout │ │ ├── Tabbar.xml │ │ └── Toolbar.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── icon.xml │ │ └── icon_round.xml │ │ ├── mipmap-hdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-mdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xxhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ ├── mipmap-xxxhdpi │ │ ├── icon.png │ │ └── launcher_foreground.png │ │ └── values │ │ ├── colors.xml │ │ └── styles.xml │ ├── PrismSerilogXamarinDemoNetStandard20.iOS │ ├── AppDelegate.cs │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon1024.png │ │ │ ├── Icon120.png │ │ │ ├── Icon152.png │ │ │ ├── Icon167.png │ │ │ ├── Icon180.png │ │ │ ├── Icon20.png │ │ │ ├── Icon29.png │ │ │ ├── Icon40.png │ │ │ ├── Icon58.png │ │ │ ├── Icon60.png │ │ │ ├── Icon76.png │ │ │ ├── Icon80.png │ │ │ └── Icon87.png │ ├── Entitlements.plist │ ├── Info.plist │ ├── Main.cs │ ├── PrismSerilogXamarinDemoNetStandard20.iOS.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Default-568h@2x.png │ │ ├── Default-Portrait.png │ │ ├── Default-Portrait@2x.png │ │ ├── Default.png │ │ ├── Default@2x.png │ │ └── LaunchScreen.storyboard │ └── iOSInitializer.cs │ └── PrismSerilogXamarinDemoNetStandard20 │ ├── App.xaml │ ├── App.xaml.cs │ ├── AssemblyInfo.cs │ ├── PrismSerilogXamarinDemoNetStandard20.csproj │ ├── ViewModels │ └── MainPageViewModel.cs │ └── Views │ ├── MainPage.xaml │ └── MainPage.xaml.cs ├── src └── Prism.Logging.Serilog │ ├── Ioc │ └── IContainerRegistryExtensions.cs │ ├── Logging │ └── Serilog │ │ └── SerilogLoggerFacade.cs │ └── Prism.Logging.Serilog.csproj └── test └── Prism.Logging.Serilog.Tests ├── Prism.Logging.Serilog.Tests.csproj ├── SerilogLoggerFacadeTests.cs └── Support ├── DelegatingSink.cs ├── Extensions.cs └── MockLoggerFacade.cs /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "cake.tool": { 6 | "version": "1.3.0", 7 | "commands": [ 8 | "dotnet-cake" 9 | ] 10 | }, 11 | "minver-cli": { 12 | "version": "4.3.0", 13 | "commands": [ 14 | "minver" 15 | ] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | end_of_line = unset 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [*.{proj,props,sln,targets,sql}] 14 | indent_style = tab 15 | 16 | [*.{xml,dna,config,nuspec,csproj,vcxproj,vcproj,targets,ps1,resx}] 17 | indent_size = 2 18 | 19 | [*.{cpp,h,def}] 20 | indent_style = tab 21 | 22 | [*.{dotsettings}] 23 | end_of_line = lf 24 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set 2 | * text=auto 3 | 4 | # Explicitly declare files that should always be converted to LF regardless of platform 5 | *.dotsettings text eol=lf 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: augustoproiete 2 | tidelift: "nuget/Prism.Logging.Serilog" 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "nuget" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | target-branch: "master" 8 | ignore: 9 | - dependency-name: "Serilog" 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "daily" 14 | target-branch: "master" 15 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-cake.yml: -------------------------------------------------------------------------------- 1 | on: 2 | schedule: 3 | # every Sunday at 6am 4 | - cron: '0 6 * * SUN' 5 | 6 | workflow_dispatch: 7 | 8 | jobs: 9 | dependabot-cake: 10 | runs-on: ubuntu-20.04 11 | steps: 12 | - name: check/update cake dependencies 13 | uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1.1.0 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore thumbnails created by Windows 2 | Thumbs.db 3 | 4 | #Ignore metadata created by OSX 5 | .DS_Store 6 | ._* 7 | 8 | #Ignore files created by Visual Studio 9 | .vs/ 10 | *.user 11 | *.suo 12 | *.tmp_proj 13 | *.cache 14 | *.vsdoc 15 | [Oo]bj/ 16 | [Bb]in/ 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | [Aa]rtifacts/ 20 | [Ll]og/ 21 | [Tt]emp/ 22 | 23 | # Ignore NuGet Packages 24 | *.nupkg 25 | **/packages/* 26 | 27 | #Ignore files created by ReSharper 28 | _ReSharper*/ 29 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | See: https://github.com/augustoproiete/prism-logging-serilog/releases 2 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @augustoproiete 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019-2023 C. Augusto Proiete & Contributors 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | | README.md | 2 | |:---| 3 | 4 |
5 | 6 | Prism.Logging.Serilog 7 | 8 |
9 | 10 |

Prism.Logging.Serilog

11 |
12 | 13 | Integrate [Serilog](https://serilog.net) with [Prism](https://prismlibrary.github.io) in your WPF, UWP, or Xamarin Forms apps. 14 | 15 | [![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) 16 | 17 | This 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. 18 | 19 |
20 | 21 | ## Give a Star! :star: 22 | 23 | If you like or are using this project please give it a star. Thanks! 24 | 25 | ## Getting started :rocket: 26 | 27 | To use the `Prism.Logging.Serilog`, first install the [NuGet package](https://nuget.org/packages/prism.logging.serilog): 28 | 29 | ```powershell 30 | Install-Package Prism.Logging.Serilog 31 | ``` 32 | 33 | Then register Serilog with Prism's `IContainerRegistry` using `RegisterSerilog()`: 34 | 35 | ```csharp 36 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 37 | { 38 | // ... 39 | 40 | containerRegistry.RegisterSerilog(); 41 | } 42 | ``` 43 | 44 | Log events from Prism will be written to Serilog's `Log.Logger` by default. Alternatively, you can provide a specific instance of a `Serilog.ILogger`: 45 | 46 | ```csharp 47 | private Serilog.ILogger _logger = Log.Logger; 48 | 49 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 50 | { 51 | // ... 52 | 53 | containerRegistry.RegisterSerilog(_logger); 54 | } 55 | ``` 56 | 57 | ## Mapping of Prism Log messages to Serilog 58 | 59 | `Prism.Logging.Serilog` does The Right Thing™ :), as you'd expect: 60 | 61 | | Prism Category | Serilog LogEventLevel | 62 | | -------------------- | --------------------------- | 63 | | `Category.Debug` | `LogEventLevel.Debug` | 64 | | `Category.Info` | `LogEventLevel.Information` | 65 | | `Category.Warn` | `LogEventLevel.Warning` | 66 | | `Category.Exception` | `LogEventLevel.Error` | 67 | 68 | * 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"`. 69 | 70 | * 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). 71 | 72 | ## Example 73 | 74 | In 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: 75 | 76 | ```csharp 77 | public partial class App 78 | { 79 | protected override void OnStartup(StartupEventArgs e) 80 | { 81 | // Configure Serilog and the sinks at the startup of the app 82 | Log.Logger = new LoggerConfiguration() 83 | .MinimumLevel.Debug() 84 | .WriteTo.File(path: "MyApp.log") 85 | .CreateLogger(); 86 | 87 | base.OnStartup(e); 88 | } 89 | 90 | protected override void OnExit(ExitEventArgs e) 91 | { 92 | // Flush all Serilog sinks before the app closes 93 | Log.CloseAndFlush(); 94 | 95 | base.OnExit(e); 96 | } 97 | 98 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 99 | { 100 | // Register your ViewModels, Services, etc... 101 | // ... 102 | 103 | // Register Serilog with Prism 104 | containerRegistry.RegisterSerilog(); 105 | } 106 | 107 | protected override Window CreateShell() 108 | { 109 | return Container.Resolve(); 110 | } 111 | } 112 | ``` 113 | 114 | ## Release History 115 | 116 | Click on the [Releases](https://github.com/augustoproiete/prism-logging-serilog/releases) tab on GitHub. 117 | 118 | --- 119 | 120 | _Copyright © 2019-2023 C. Augusto Proiete & Contributors - Provided under the [Apache License, Version 2.0](LICENSE)._ 121 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Security contact information 2 | 3 | To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 4 | -------------------------------------------------------------------------------- /assets/prism-nuget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/augustoproiete/prism-logging-serilog/fbde3da757c845976e77dd24991ddf692572704b/assets/prism-nuget.png -------------------------------------------------------------------------------- /assets/prism.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/augustoproiete/prism-logging-serilog/fbde3da757c845976e77dd24991ddf692572704b/assets/prism.snk -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "allowPrerelease": false, 4 | "version": "3.1.100", 5 | "rollForward": "latestFeature" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /prism-logging-serilog.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29201.188 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{2E38532A-A66C-498A-8FBF-4D6FE6F31ECC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrismSerilogWpfDemoNet45", "sample\net45\PrismSerilogWpfDemoNet45\PrismSerilogWpfDemoNet45.csproj", "{CB57A3B5-DDC6-48C3-B031-7216A83A2970}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A918D06F-30C4-48CA-8E75-90131BA4B8D8}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Logging.Serilog", "src\Prism.Logging.Serilog\Prism.Logging.Serilog.csproj", "{88146B27-E104-4939-99FD-70557287F877}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{2CB13D58-3C7B-4AAA-8ADD-F0C3CD52EEE4}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Logging.Serilog.Tests", "test\Prism.Logging.Serilog.Tests\Prism.Logging.Serilog.Tests.csproj", "{49AF6C05-BB7C-437D-B163-813939457192}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{C8C51579-94E5-400E-914C-3616DBAEBF49}" 19 | EndProject 20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "netcoreapp3.0", "netcoreapp3.0", "{845167A8-94BF-43C0-B1AD-878B47FDA827}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrismSerilogWpfDemoNetCoreApp30", "sample\netcoreapp3.0\PrismSerilogWpfDemoNetCoreApp30\PrismSerilogWpfDemoNetCoreApp30.csproj", "{D16CA8E1-8130-4E9D-8AD2-856F6768DC0C}" 23 | EndProject 24 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "netstandard2.0", "netstandard2.0", "{327D087D-2A5E-487B-BCFE-C2EE8EAC3FC7}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrismSerilogXamarinDemoNetStandard20", "sample\netstandard2.0\PrismSerilogXamarinDemoNetStandard20\PrismSerilogXamarinDemoNetStandard20\PrismSerilogXamarinDemoNetStandard20.csproj", "{BF0EB14A-E346-486B-B27E-3F9632A5F16E}" 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrismSerilogXamarinDemoNetStandard20.Android", "sample\netstandard2.0\PrismSerilogXamarinDemoNetStandard20\PrismSerilogXamarinDemoNetStandard20.Android\PrismSerilogXamarinDemoNetStandard20.Android.csproj", "{4D03E699-7664-42A4-8A4C-03E69830B120}" 29 | EndProject 30 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrismSerilogXamarinDemoNetStandard20.iOS", "sample\netstandard2.0\PrismSerilogXamarinDemoNetStandard20\PrismSerilogXamarinDemoNetStandard20.iOS\PrismSerilogXamarinDemoNetStandard20.iOS.csproj", "{C2327E37-42DC-4154-95DA-47CBC123890F}" 31 | EndProject 32 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E6D8E5BF-215F-4E52-BD7F-1AD11A7553C1}" 33 | ProjectSection(SolutionItems) = preProject 34 | .editorconfig = .editorconfig 35 | .gitattributes = .gitattributes 36 | .gitignore = .gitignore 37 | CHANGES.md = CHANGES.md 38 | CODEOWNERS = CODEOWNERS 39 | global.json = global.json 40 | LICENSE = LICENSE 41 | README.md = README.md 42 | SECURITY.md = SECURITY.md 43 | EndProjectSection 44 | EndProject 45 | Global 46 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 47 | Debug|Any CPU = Debug|Any CPU 48 | Release|Any CPU = Release|Any CPU 49 | EndGlobalSection 50 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 51 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 52 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970}.Debug|Any CPU.Build.0 = Debug|Any CPU 53 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970}.Release|Any CPU.Build.0 = Release|Any CPU 55 | {88146B27-E104-4939-99FD-70557287F877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {88146B27-E104-4939-99FD-70557287F877}.Debug|Any CPU.Build.0 = Debug|Any CPU 57 | {88146B27-E104-4939-99FD-70557287F877}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 | {88146B27-E104-4939-99FD-70557287F877}.Release|Any CPU.Build.0 = Release|Any CPU 59 | {49AF6C05-BB7C-437D-B163-813939457192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 60 | {49AF6C05-BB7C-437D-B163-813939457192}.Debug|Any CPU.Build.0 = Debug|Any CPU 61 | {49AF6C05-BB7C-437D-B163-813939457192}.Release|Any CPU.ActiveCfg = Release|Any CPU 62 | {49AF6C05-BB7C-437D-B163-813939457192}.Release|Any CPU.Build.0 = Release|Any CPU 63 | {D16CA8E1-8130-4E9D-8AD2-856F6768DC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 64 | {D16CA8E1-8130-4E9D-8AD2-856F6768DC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU 65 | {D16CA8E1-8130-4E9D-8AD2-856F6768DC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU 66 | {D16CA8E1-8130-4E9D-8AD2-856F6768DC0C}.Release|Any CPU.Build.0 = Release|Any CPU 67 | {BF0EB14A-E346-486B-B27E-3F9632A5F16E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 68 | {BF0EB14A-E346-486B-B27E-3F9632A5F16E}.Debug|Any CPU.Build.0 = Debug|Any CPU 69 | {BF0EB14A-E346-486B-B27E-3F9632A5F16E}.Release|Any CPU.ActiveCfg = Release|Any CPU 70 | {BF0EB14A-E346-486B-B27E-3F9632A5F16E}.Release|Any CPU.Build.0 = Release|Any CPU 71 | {4D03E699-7664-42A4-8A4C-03E69830B120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 72 | {4D03E699-7664-42A4-8A4C-03E69830B120}.Debug|Any CPU.Build.0 = Debug|Any CPU 73 | {4D03E699-7664-42A4-8A4C-03E69830B120}.Release|Any CPU.ActiveCfg = Release|Any CPU 74 | {4D03E699-7664-42A4-8A4C-03E69830B120}.Release|Any CPU.Build.0 = Release|Any CPU 75 | {C2327E37-42DC-4154-95DA-47CBC123890F}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator 76 | {C2327E37-42DC-4154-95DA-47CBC123890F}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator 77 | {C2327E37-42DC-4154-95DA-47CBC123890F}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator 78 | {C2327E37-42DC-4154-95DA-47CBC123890F}.Release|Any CPU.Build.0 = Release|iPhoneSimulator 79 | EndGlobalSection 80 | GlobalSection(SolutionProperties) = preSolution 81 | HideSolutionNode = FALSE 82 | EndGlobalSection 83 | GlobalSection(NestedProjects) = preSolution 84 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970} = {C8C51579-94E5-400E-914C-3616DBAEBF49} 85 | {88146B27-E104-4939-99FD-70557287F877} = {A918D06F-30C4-48CA-8E75-90131BA4B8D8} 86 | {49AF6C05-BB7C-437D-B163-813939457192} = {2CB13D58-3C7B-4AAA-8ADD-F0C3CD52EEE4} 87 | {C8C51579-94E5-400E-914C-3616DBAEBF49} = {2E38532A-A66C-498A-8FBF-4D6FE6F31ECC} 88 | {845167A8-94BF-43C0-B1AD-878B47FDA827} = {2E38532A-A66C-498A-8FBF-4D6FE6F31ECC} 89 | {D16CA8E1-8130-4E9D-8AD2-856F6768DC0C} = {845167A8-94BF-43C0-B1AD-878B47FDA827} 90 | {327D087D-2A5E-487B-BCFE-C2EE8EAC3FC7} = {2E38532A-A66C-498A-8FBF-4D6FE6F31ECC} 91 | {BF0EB14A-E346-486B-B27E-3F9632A5F16E} = {327D087D-2A5E-487B-BCFE-C2EE8EAC3FC7} 92 | {4D03E699-7664-42A4-8A4C-03E69830B120} = {327D087D-2A5E-487B-BCFE-C2EE8EAC3FC7} 93 | {C2327E37-42DC-4154-95DA-47CBC123890F} = {327D087D-2A5E-487B-BCFE-C2EE8EAC3FC7} 94 | EndGlobalSection 95 | GlobalSection(ExtensibilityGlobals) = postSolution 96 | SolutionGuid = {7215B999-A555-49A3-ACCA-ABF01EE7C25B} 97 | EndGlobalSection 98 | EndGlobal 99 | -------------------------------------------------------------------------------- /prism-logging-serilog.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | DO_NOT_SHOW 3 | DO_NOT_SHOW 4 | DO_NOT_SHOW 5 | DO_NOT_SHOW 6 | DO_NOT_SHOW 7 | DO_NOT_SHOW 8 | DO_NOT_SHOW 9 | DO_NOT_SHOW 10 | DO_NOT_SHOW 11 | DO_NOT_SHOW -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/App.xaml.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2019-2023 C. Augusto Proiete & Contributors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #endregion 16 | 17 | using System.Text; 18 | using System.Windows; 19 | using Prism.Ioc; 20 | using Serilog; 21 | using PrismSerilogWpfDemoNet45.Views; 22 | 23 | namespace PrismSerilogWpfDemoNet45 24 | { 25 | public partial class App 26 | { 27 | protected override void OnStartup(StartupEventArgs e) 28 | { 29 | Log.Logger = new LoggerConfiguration() 30 | .MinimumLevel.Debug() 31 | .WriteTo.File(path: "DemoLog.txt", encoding: Encoding.UTF8) 32 | .CreateLogger(); 33 | 34 | base.OnStartup(e); 35 | } 36 | 37 | protected override void OnExit(ExitEventArgs e) 38 | { 39 | Log.CloseAndFlush(); 40 | 41 | base.OnExit(e); 42 | } 43 | 44 | protected override void RegisterTypes(IContainerRegistry containerRegistry) 45 | { 46 | containerRegistry.RegisterSerilog(); 47 | } 48 | 49 | protected override Window CreateShell() 50 | { 51 | return Container.Resolve(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/PrismSerilogWpfDemoNet45.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CB57A3B5-DDC6-48C3-B031-7216A83A2970} 8 | WinExe 9 | PrismSerilogWpfDemoNet45 10 | PrismSerilogWpfDemoNet45 11 | v4.5 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | ..\..\..\packages\CommonServiceLocator.2.0.4\lib\net45\CommonServiceLocator.dll 39 | 40 | 41 | ..\..\..\packages\Prism.Core.7.2.0.1422\lib\net45\Prism.dll 42 | 43 | 44 | ..\..\..\packages\Prism.Unity.7.2.0.1422\lib\net45\Prism.Unity.Wpf.dll 45 | 46 | 47 | ..\..\..\packages\Prism.Wpf.7.2.0.1422\lib\net45\Prism.Wpf.dll 48 | 49 | 50 | ..\..\..\packages\Serilog.2.8.0\lib\net45\Serilog.dll 51 | 52 | 53 | ..\..\..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll 54 | 55 | 56 | 57 | 58 | 59 | 60 | ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll 61 | 62 | 63 | ..\..\..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll 64 | 65 | 66 | ..\..\..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll 67 | 68 | 69 | ..\..\..\packages\Prism.Wpf.7.2.0.1422\lib\net45\System.Windows.Interactivity.dll 70 | 71 | 72 | 4.0 73 | 74 | 75 | ..\..\..\packages\Unity.Abstractions.5.11.1\lib\net45\Unity.Abstractions.dll 76 | 77 | 78 | ..\..\..\packages\Unity.Container.5.11.1\lib\net45\Unity.Container.dll 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | MSBuild:Compile 87 | Designer 88 | 89 | 90 | MSBuild:Compile 91 | Designer 92 | 93 | 94 | App.xaml 95 | Code 96 | 97 | 98 | 99 | MainWindow.xaml 100 | Code 101 | 102 | 103 | 104 | 105 | Code 106 | 107 | 108 | True 109 | True 110 | Resources.resx 111 | 112 | 113 | True 114 | Settings.settings 115 | True 116 | 117 | 118 | ResXFileCodeGenerator 119 | Resources.Designer.cs 120 | 121 | 122 | 123 | SettingsSingleFileGenerator 124 | Settings.Designer.cs 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | {88146b27-e104-4939-99fd-70557287f877} 133 | Prism.Logging.Serilog 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | [assembly: AssemblyTitle("PrismSerilogWpfDemoNet45")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("augustoproiete.net")] 9 | [assembly: AssemblyProduct("PrismSerilogWpfDemoNet45")] 10 | [assembly: AssemblyCopyright("Copyright 2019-2023 C. Augusto Proiete & Contributors")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: ThemeInfo( 17 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 18 | //(used if a resource is not found in the page, 19 | // or application resource dictionaries) 20 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 21 | //(used if a resource is not found in the page, 22 | // app, or any theme specific resource dictionaries) 23 | )] 24 | 25 | [assembly: AssemblyVersion("1.0.0.0")] 26 | [assembly: AssemblyFileVersion("1.0.0.0")] 27 | [assembly: AssemblyInformationalVersion("1.0.0")] 28 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PrismSerilogWpfDemoNet45.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PrismSerilogWpfDemo.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PrismSerilogWpfDemoNet45.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2019-2023 C. Augusto Proiete & Contributors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | #endregion 16 | 17 | using System; 18 | using System.IO; 19 | using System.Text; 20 | using Prism.Commands; 21 | using Prism.Logging; 22 | using Prism.Mvvm; 23 | 24 | namespace PrismSerilogWpfDemoNet45.ViewModels 25 | { 26 | public class MainWindowViewModel : BindableBase 27 | { 28 | private readonly ILoggerFacade _logger; 29 | private string _title = "Prism Serilog WPF Demo (.NET 4.5)"; 30 | 31 | public MainWindowViewModel(ILoggerFacade logger) 32 | { 33 | _logger = logger ?? throw new ArgumentNullException(nameof(logger)); 34 | 35 | LogDebugCommand = new DelegateCommand(LogDebug); 36 | LogInformationCommand = new DelegateCommand(LogInformation); 37 | LogWarningCommand = new DelegateCommand(LogWarning); 38 | LogExceptionCommand = new DelegateCommand(LogException); 39 | } 40 | 41 | public string Title 42 | { 43 | get => _title; 44 | set => SetProperty(ref _title, value); 45 | } 46 | 47 | public string Text 48 | { 49 | get 50 | { 51 | const string logFileName = "DemoLog.txt"; 52 | 53 | if (!File.Exists(logFileName)) 54 | { 55 | return null; 56 | } 57 | 58 | // FileShare.ReadWrite required for Serilog to continue writing - File.ReadAllText doesn't allow that 59 | using (var stream = new FileStream(logFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) 60 | { 61 | using (var reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true)) 62 | { 63 | return reader.ReadToEnd(); 64 | } 65 | } 66 | } 67 | } 68 | 69 | public DelegateCommand LogDebugCommand { get; } 70 | public DelegateCommand LogInformationCommand { get; } 71 | public DelegateCommand LogWarningCommand { get; } 72 | public DelegateCommand LogExceptionCommand { get; } 73 | 74 | private void LogDebug() 75 | { 76 | _logger.Log("This is a Debug message!", Category.Debug, Priority.High); 77 | 78 | RaisePropertyChanged(nameof(Text)); 79 | } 80 | 81 | private void LogInformation() 82 | { 83 | _logger.Log("This is an Information message!", Category.Info, Priority.High); 84 | 85 | RaisePropertyChanged(nameof(Text)); 86 | } 87 | 88 | private void LogWarning() 89 | { 90 | _logger.Log("This is an Warning message!", Category.Warn, Priority.High); 91 | 92 | RaisePropertyChanged(nameof(Text)); 93 | } 94 | 95 | private void LogException() 96 | { 97 | _logger.Log("This is an Exception message!", Category.Exception, Priority.High); 98 | 99 | RaisePropertyChanged(nameof(Text)); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /sample/net45/PrismSerilogWpfDemoNet45/Views/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | Log messages are being written to `DemoLog.txt` 12 | 13 | 14 | 15 |