Current behavior
- Choosing Serilog + Configuration for creating a new uno app, does not provide a Serilog Configuration Section
- Current Uno App Template including Serilog produces just the current routes from Navigation Extensions
- if we set the LogLevel in the always (with any available Logging Feature), included Uno own
UseLogging(...) Hostbuilder, this (of course) doesn't affect the Serilog.ILogger behaviour
What we currently get is this here in appsettings.json:
{
"AppConfig": {
"Environment": "Production"
},
"ApiClient": {
"UseNativeHandler": true
}
}
and this here in appsettings.development.json:
{
"AppConfig": {
"Environment": "Development"
},
"ApiClient": {
"Url": "https://localhost:5002",
"UseNativeHandler": true
}
}
Expected behavior
- Configureation section for Serilog should be included if we did choose Serilog in a new app
- LogLevel Switching Support also if we are not using Uno Extensions Logging itself, since we normally should stay with the same pattern AND Uno.Extensions.Logging has NO compartibility Layer for us using Serilog
- FilePath should be respected from the Uno Serilog extension and if Uno overrides of this silently with
IAppHostEnvironment.AppDataPath & HostBuilderExtensions.cs#GetLogFilePath there should be any Notice about this in the Docs!
- If our Serilog Section from
appsettings.json includes Template or our manual HostBuilder configuration includes a ExpressionTemplate, this MUST be respected from the Uno Serilog extension! currently, Users of the Android & iOS TFM's seems to get a not very nice surprise when inspecting the src code used under the hood by the way, same just across all TFM's applyies to the ExpressionTemplate applyed for the Console Logging 🙄
- Sample configuration could be something like this, which is not included in the Currently by the Uno Extensions Docs linked
Serilog/Getting-Started.md wiki:
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": { "path": "%TEMP%/UnoApp4/Logs/log.txt" }
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "UnoApp4"
}
}
}
Including those sampled Serilog section and starting our Uno App, does then provide the Logging output WITH content more then the current routes from Navigation Extensions: CUsersSonjasourcesamplesUnoApp4UnoApp4binDebugnet9.0-desktopUnoApp4.exe.txt
Affected platforms
- iOS
- Android
- WebAssembly
- Skia
- Windows (WinAppSdk)
- Server
Template Host
Visual Studio
Host OS
Windows
Template Options
Choosen Serilog, got both logging options (mentioned on #1657 )
<UnoFeatures>
Material;
Hosting;
Toolkit;
Logging;
LoggingSerilog;
MVUX;
Configuration;
HttpRefit;
Serialization;
Authentication;
Navigation;
SkiaRenderer;
</UnoFeatures>
Targets: Desktop net 9
Template Version
Uno Extension version 6.2.11.11
Anything else we need to know?
HostBuilder Differences:
- since the
Uno.Extension.Logging.Serilog > HostBuilderExtensions instructs Serilog to read from Configuration, but is not aligning with the common Uno.Extensions.* .Use*(...) Signature. So we can not provide a IConfigurationSection for example, but not even a string sectionName, if we would possibly like to nest our Logging Config into ONE
- Serilog is also not even aligning with the regular Uno own Logging Framework provided by
Uno.Extensions.Logging and based upon Microsoft.Extensions.Logging. For example, Uno.Extensions.Logging does provide those Signatures:
.UseLogging(this IHostBuilder hostbuilder, Action<HostbuilderContext,ILoggingBuilder> configure)
.UseLogging(this IHostbuilder hostbuilder, Action<LoggingBuilder> configure)
Documentation?
Current behavior
UseLogging(...)Hostbuilder, this (of course) doesn't affect theSerilog.ILoggerbehaviourWhat we currently get is this here in
appsettings.json:{ "AppConfig": { "Environment": "Production" }, "ApiClient": { "UseNativeHandler": true } }and this here in
appsettings.development.json:{ "AppConfig": { "Environment": "Development" }, "ApiClient": { "Url": "https://localhost:5002", "UseNativeHandler": true } }Expected behavior
IAppHostEnvironment.AppDataPath& HostBuilderExtensions.cs#GetLogFilePath there should be any Notice about this in the Docs!appsettings.jsonincludesTemplateor our manual HostBuilder configuration includes aExpressionTemplate, this MUST be respected from the Uno Serilog extension! currently, Users of the Android & iOS TFM's seems to get a not very nice surprise when inspecting the src code used under the hood by the way, same just across all TFM's applyies to the ExpressionTemplate applyed for the Console Logging 🙄Serilog/Getting-Started.mdwiki:{ "Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], "MinimumLevel": "Debug", "WriteTo": [ { "Name": "Console" }, { "Name": "File", "Args": { "path": "%TEMP%/UnoApp4/Logs/log.txt" } } ], "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], "Properties": { "Application": "UnoApp4" } } }Including those sampled Serilog section and starting our Uno App, does then provide the Logging output WITH content more then the current routes from Navigation Extensions: CUsersSonjasourcesamplesUnoApp4UnoApp4binDebugnet9.0-desktopUnoApp4.exe.txt
Affected platforms
Template Host
Visual Studio
Host OS
Windows
Template Options
Choosen Serilog, got both logging options (mentioned on #1657 )
Targets: Desktop net 9
Template Version
Anything else we need to know?
HostBuilder Differences:
Uno.Extension.Logging.Serilog > HostBuilderExtensionsinstructs Serilog to read from Configuration, but is not aligning with the commonUno.Extensions.*.Use*(...)Signature. So we can not provide aIConfigurationSectionfor example, but not even astring sectionName, if we would possibly like to nest our Logging Config into ONEUno.Extensions.Loggingand based uponMicrosoft.Extensions.Logging. For example, Uno.Extensions.Logging does provide those Signatures:.UseLogging(this IHostBuilder hostbuilder, Action<HostbuilderContext,ILoggingBuilder> configure).UseLogging(this IHostbuilder hostbuilder, Action<LoggingBuilder> configure)Documentation?
The Uno Templates docs do NOT include one single line, that would at least let us know about that missing configuration Section, how to set it up, or where to get if from, so instead we we are getting a "nice" (sarcasm) little surprise and additional ToDo for our list for free 👎
Indeed, the Serilog Extension from Uno misses almost ANY Docs except from the mention of the
UnoFeaturesIDLoggingSerilog;and the pure existance ofUseSerilog()The Uno Serilog docs are ONLY providing a Non-Configuration Link to the Serilog Wiki "Getting Started" from where we still are required to search future for this
To get File Logs, this Link would also be valuable
Json appsettings.json configurationHeader inSerilog-sings-fileRepo Readme this Repo redirected me for example then to the appropriateSerilog.Settings.ConfigurationRepo, which then included finally the above used sample configuration Section, (not included in theGet-Started.mdWiki mentioned before!) which misses in the Uno Docs and should be added to the docs, since Uno provides great Configuration Extensions