0

I am trying to create a concrete implementation of ILogger in python using the build in python logger.

However, when I try to implement the ILogger interface, I'm getting the exception

Method 'Log' in type 'Microsoft.Extensions.Logging.PyLogger' from assembly 'Python.Runtime.Dynamic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

The code so far is simple and incomplete

class PyLogger(ILogger):
    __namespace__ = "Microsoft.Extensions.Logging"

    def Log(self, logLevel, eventId, state, exception, formatter):
        print(logLevel, eventId, state, exception, formatter)
        return
    
    def IsEnabled(self):
        return True

I don't understand why it doesn't like my Log definition. When I inspect ILogger.Log it get the following, which looks complete.

>>> inspect.signature(ILogger.Log)
<Signature (logLevel, eventId, state, exception, formatter)>
  • Not a complete answer, but it may have something to do with the expected extension methods https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger?view=dotnet-plat-ext-7.0 There are multiple other signatures of Log. – Denise Skidmore Jul 24 '23 at 03:53

0 Answers0