Search code examples
builduno-platform

Uno ILoggerFactory does not contain definition AddConsole


I am attempting to build a uno-platform app and, immediately, I get an error

Error CS1929 'ILoggerFactory' does not contain a definition for 'AddConsole' 
and the best extension method overload 'ConsoleLoggerExtensions.AddConsole(ILoggingBuilder, 
Action<ConsoleLoggerOptions>)' requires a receiver of type 'ILoggingBuilder'    
UnoTest.Droid, UnoTest.UWP, UnoTest.Wasm, UnoTest.iOS, UnoTest.macOS

I have package microsoft.extensions.logging.console version 5.0.0 installed, as well as microsoft.extensions.logging.filter version 1.1.2.

And the source code does have using Microsoft.Extensions.Logging;

I have the suspicion that there may be some backwards compatibility issue with the referenced API.


Solution

  • Uno Platform isn't compatible with versions of Microsoft.Extensions.Logging.Console above 1.1.1. The reason is that later versions use threading APIs which currently don't function on WebAssembly (which is single-threaded only).

    If possible, downgrade the installed versions of Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Logging.Filter to 1.1.1.