Skip to content

[Serilog] Clarification Request: can we use Generic ILoggers when we choose Serilog in Uno? #2896

Open

Description

@DevTKSS

What would you like clarification on

While there is at the moment duplicated Logging setup in our Uno apps, lets say we would just "clean" this ourselfs and just left over the UseSerilog(consoleLoggingEnabled: true, fileLoggingEnabled: true) we are getting preset from the templetes.

  1. the 3rd optional Argument for configuring Serilog in our hostbuilder for getting just the same as in the non-file logging Microsoft+Uno Generic Loggers with context.HostingEnvironment.IsDevelopment() ? LogLevel.Information : LogLevel.Warning is not having an HostContext Parameter overload to get the HostingEnvironment like that. How are we meant to implement a MinimumLevel.ControlledBy(... just like that in our uno apps using Serilog?
  2. How are we meant to have the Context specific logger in the DI ctor injected? With Microsoft.Extensions.Logging usage Uno allowes us to use ILogger<T> and in the Backing Field ILogger but that doesnt work when using the Uno Feature LoggingSerilog without the Basic Logging and giving an compiler error of CS0308: The non-generic type 'ILogger' cannot be used with type arguments

Concern?

  • Usage in industry
  • Clarification of capabilities
  • Getting started with Uno -> little to none Uno.Extensions.Serilog Docs existing!
  • Developing with Uno
  • Contributing to the Uno project
  • Publishing your application -> not possible to use this UnoFeature to have Logs in Production!
  • Support
  • Other (please specify):

For which Platform

  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Android
  • WebAssembly
  • Windows
  • Skia Desktop
  • Build tasks

Anything else we need to know?

tryed to use exactly that in a business application last week and even tryed with the regular ms hostbuilder+ uno feature (!) since there seem to be no "Platform" available if you want to use the UnoFeatures in a Console Application, but never got file logs or that linting going away. My only chance was using Log.Error for example, but even then there were no Logs ever created!
To check if thats only caused through the Console app type maybe, I tryed using Serilog in my Desktop targeting App and attached Library Project, but there is no chance to get a generic typed ILogger without code changes implemented in Library Projects at all. so the result would be, you would need anybody who might use your Library as Dependency in the future, to must use Seriog OR you will not be able to use it in your library(?) and by this not having the option of using File logs.

My current workaround is to have a non-generic DI parameter of ILogger and then before putting it into the backing field is logger.ForContext<MyService>() but there seems to be no pre existing way to do this using the uno extension for serilog

Thats why I would like some clarification about how we might be meant to use that in our apps and realistically also in our Production apps, which I would be targeting to do at the end of the road.

Activity

  1. added
    kind/consumer-experience
    kind/documentation
    triage/untriaged
    on Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/consumer-experiencekind/documentationtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions