Commit 755eb19
committed
feat: ILoggingBuilder.AddSerilog() extension method
Context: #3008
Context: #3011
Context: unoplatform/uno.templates#1921
Issue #3008 details that there are two `ILogger` "environments" in
a Uno app:
* The `App.InitializeLogging()` environment ("NoDI"), and
* The environment configured by Dependency Injection methods such
as `.UseLogging()` and `.UseSerilog()` ("DI").
The problem is that "DI" logging *cannot* capture log messages
produced before the DI environment is built, frequently via
`builder.Build()` or `builder.NavigateAsync<TShell>()`.
*A lot* of code can execute before those methods complete.
A further problem is that no default template actually configures
both environments: if you use `dotnet new unoapp -di False` you
get the NoDI `App.InitializeLogging()` environment, which
*will not* log messages from the Dependency Injection enviornment.
If you use `dotnet new unoapp -preset "recommended"` you get
*only* the DI-based logging, thus missing all messages from the
NoDI environment.
Thus, the idea for "`ILogger` configuration unification": What If
instead of having two separate places for logging, we just had one:
the NoDI `App.InitializeLogging()` location.
This can be made to work via #3011, which updates
`HostBuilder.Build()` so that *if*
`LogExtensionPoint.AmbientLoggerFactory` is set, it *replaces* the
`ILoggerFactory` that `HostBuilder.Build()` normally configures.
This allows `App.InitializeLogging()` to also be used in the DI
environment.
So far, so useful.
But what about [Serilog][0]? Serilog is a widely recommended logger
library, and the current `.UseSerilog()` extension method *requires*
a full Dependency Injection environment: it cannot be invoked within
`App.InitializeLogging()`.
Try to square this circle by adding a new
`ILoggingBuilder.AddSerilog()` extension method. This would allow
Serilog to be configured within `App.InitializeLogging()`, helping
to support a unified logging setup experience.
[0]: https://platform.uno/docs/articles/external/uno.extensions/doc/Overview/Logging/LoggingOverview.html#serilog1 parent 5235975 commit 755eb19
File tree
4 files changed
+60
-2
lines changed- src
- Uno.Extensions.Core.UI
- Uno.Extensions.Logging.Serilog
4 files changed
+60
-2
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
0 commit comments