Closed darknessWONG closed 2 years ago
Hi I might be a bit late, but I got into using this library just today and found, that the reason why your logger might not log outside it's creating method is the line:
using var loggerFactory = LoggerFactory.Create(builder =>
in my application I had to get rid of the using, in order to get it to work. I know that this is bad practice and should be avoided as much as possible, but in my case I'm using the logger in a small application to temporarily monitor some network I/O.
But I really don't get why invoking Dispose on the factory should cause the logger to break. It obviously works perfectly when logging to console. To me this looks almost, as if the logger or part of the logger gets disposed as soon as the factory is disposed.
So my code looks similar to this:
var loggerFactory = LoggerFactory.Create(builder =>
Please keep in mind, that in this case you should assign LoggerFactory to a variable which will be disposed later.
Hopefully this might help someone who stumbles across this issue in the future. :)
oh, thank you to replay me! I tried the way you suggested, It's works.
Thank you very much!
Hi, Thanks for your logging module, but I have got some issues when using it.
Logger can only work in the function that be created. Here is my code: Program.cs
Backend.Common.Log.LogUtils:
But all of these can output to console. Here is the output in console:
And this is the output in file: