1

Below is sample code for passing Microsoft.Extensions.logging as input of logging partial method.but my scenarios is how pass Serilog.Ilogger as input of logging partial method.

  [LoggerMessage(EventId = 0, Level = LogLevel.Information, Message = "Generating {customer}")]
    private static partial void LogCustomerCreated(
ILogger logger, [LogProperties] Customer customer);
1
  • Same issue here, haven't find the solution Commented Jul 18, 2024 at 13:53

1 Answer 1

1

To use Serilog with Microsof.Extention.Loggin you need to use this package "Serilog.Extensions.Logging".

You then need to create the Ilogger with LoggerFactory

SerilogLoggerFactory loggerFactory = new SerilogLoggerFactory();

ILogger<Program> newLogger = loggerFactory.CreateLogger<Program>();
DataProcessor dataProcessor = new(loggerFactory.CreateLogger<DataProcessor>());

Can you share more information about the part where you create the log

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.