-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InMemorySink doesn't see log entries #12
Comments
Hi @brentarias! Internally the InMemorySink uses an |
I have an update. I found a workaround. I'm using To say this differently, I chose to syphon off the |
To answer your question, the initialization is enacted within a unit test framework:
So yes, I could say it is in an async context. All the test methods are also async. It is within the above method that I have chosen to "pre-capture" the InMemorySink value, before it becomes "corrupt" or lost. |
Ok that's indeed for MSTest the approach I usually take as well. |
As of now I discovered that if I simply change the signature to remove |
Still good to know, I’ll see if I can do something about that because I imagine more people might bump into this |
All of my plugins have an associated plugin test project. All of those test projects use |
My solution was to wait before checking the log.
|
@xavierjohn that's interesting, it should mean that the logger isn't flushed somehow. I would imagine that a |
The real problem here is that Without improvements to InMemorySink inMemorySink = new();
LoggerConfiguration loggerConfiguration = new();
loggerConfiguration.WriteTo.Sink(inMemorySink);
ILogger logger = loggerConfiguration.CreateLogger();
logger.Information("Hello, World!");
inMemorySink.LogEvents.Should().ContainSingle(a => a.MessageTemplate.Text == "Hello, World!"); |
I have a plugin architecture where a half dozen plugins correctly find InMemorySink.Instance containing log entries...as expected. However, I have one plugin that uses the exact same code...but InMemorySink.Instance is empty. The screenshot below shows that the inmemory sink has indeed collected entries, but the static access point doesn't see them.
At the point where I call
CreateLogger
, I have run the following identity checks:When I run those same three checks at the location seen in the screenshot below, the results are as follows:
assembles
var shows the InMemory assembly location is the same in both places.inmem
var shows that the hash code of the InMemory assembly is the same in both places.hash
var shows that the staticInMemorySink.Instance
has indeed changed values!I conclude from this that there is no funny business regarding mismatched DLL's or DLL versions. Instead it seems that internally, InMemory is somehow overwriting its static value. This seems like a bug.
Please help. :)
The text was updated successfully, but these errors were encountered: