One way to achieve this would be to implement your own implementation of the ILoggerFactory and ILogger classes. i.e.
public class MyLoggerFactory : ILoggerFactory {...} public class MyConsoleLogger : ILogger {...}
You can take a look at the implementations of Microsoft's built in logging and create your own based on these as needed: https://github.com/aspnet/Logging/tree/dev/src/Microsoft.Extensions.Logging
This will allow you to override the default Log methods and even create your own overrides which identity it as user logged vs system logged or whatever you need from it.
Once you have your own implementations you can then register it like the following:
//Register logging var loggerConfig = Configuration.GetValue("Logging", new MyLoggingConfig()); var loggerFactory = new MyLoggerFactory(loggerConfig); services.AddSingleton(typeof(ILoggerFactory), loggerFactory); services.AddLogging();
I have done this in a test project of mine and it works well for us. You can also create other implementations of logging if needed i.e a database logger