You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There could be a simple answer to this, and to be honest it seems to me to be context related. However, I figured I'd post here see if it get's a conversation started. In my scenario I have a class which hosts the LoggerFactory and is used to create a logger
private readonly ILoggerFactory _loggerFactory;
private readonly ILogger<MyClass> _logger;
public MyClass()
{
_loggerFactory = new LoggerFactory().AddSerilog(dispose: true);
_logger = _loggerFactory.CreateLogger<MyClass>();
}
Logging works as expected as long as I am awaiting all my async methods or the method is synchronous. But, when I call _logger from a task I am not seeing those entries come through.
I was able to get log entries to work by creating another logger within the Configure() method scope: var scopedLogger = _loggerFactory.CreateLogger("ConfigurationLogger"); and calling scopedLogger from within the Task.
I am curious to what I am missing or if this is a legit issue
The text was updated successfully, but these errors were encountered:
Nothing immediately comes to mind, @samirbanjanovic - I hope you found some clues somewhere. Closing as this issue is now a bit stale, but if you did end up tracking this down to something Serilog-related please let us know :-)
There could be a simple answer to this, and to be honest it seems to me to be context related. However, I figured I'd post here see if it get's a conversation started. In my scenario I have a class which hosts the LoggerFactory and is used to create a logger
Logging works as expected as long as I am awaiting all my async methods or the method is synchronous. But, when I call
_logger
from a task I am not seeing those entries come through.The code below yields now log entry:
I was able to get log entries to work by creating another logger within the
Configure()
method scope:var scopedLogger = _loggerFactory.CreateLogger("ConfigurationLogger");
and callingscopedLogger
from within the Task.I am curious to what I am missing or if this is a legit issue
The text was updated successfully, but these errors were encountered: