Comments (10)
Try using this line instead:
LogicalThreadContext.Properties["FirstName"] = "Alice";
from log4stash.
We rely on IDisposable returned from Push. Could you help us understand how this will fix the ArgumentNullException?
from log4stash.
Look at https://github.com/urielha/log4stash/blob/master/src/log4stash/LogEvent/BasicLoggingEventParser.cs line 111 method.
It takes its values from the properties of the thread context and not the stack, these are different storages.
Therefore, you need to use properties with the current code.
Or, you can add a pull request with a way to sort it out.
from log4stash.
Based on my experiments it is a bug ConvertToArrayFilter. When I turn it off by removing <ToArray>
in the config, the exception disappears. The underlying issue that we were having also goes away. The ArgumentNullException prevented further logging. Removing <ToArray>
filter fixed that.
So based on that, the issue is not related to Properties vs Stack. We've been using Stack for a long time and it always, and still, works.
from log4stash.
You are right, it does work, my bad :)
Anyways, it seems either somehow instead of "Alice" you send null or somehow the value is overwritten to null in log4stash
from log4stash.
You are right, it does work, my bad :)
Anyways, it seems either somehow instead of "Alice" you send null or somehow the value is overwritten to null in log4stash
We remove "Alice" by calling IDisposable.Dispose. I updated the bug description with a code sample.
from log4stash.
From what I see, since you dispose "Alice" before logging without popping it from the stack it stays null and therefore causes the exception,
I debugged log4stash with a sample code similar to yours and that's what I saw
from log4stash.
My understanding is that explicit Pop call is not required. Based on log4net documentation for the Push, they seem to recommend this pattern:
using(log4net.LogicalThreadContext.Stacks["NDC"].Push("Stack_Message"))
{
log.Warn("This should have an ThreadContext Stack message");
}
from log4stash.
It was my understanding too, but in fact that's what happens when debugging the code
from log4stash.
I have do a bit more research on this, but IMHO ToArray filter needs to be fixed to behave like ToString filter. ToString does not crash in the same scenario.
from log4stash.
Related Issues (20)
- Aliases for Index
- Using the template returns not data HOT 1
- Custom log4net values get submitted as { "Count": 1 } HOT 2
- Does not work with log4net 2.0.8 or higher HOT 5
- Unable to push logs to https elasticsearch from aspnet core HOT 3
- Not clear what these properties do HOT 1
- log4stash v3.0.0 doesn't work with ElasticSearch 6.x HOT 1
- Log4Stash logging metadata info by itself HOT 2
- AWS Signature failure - Incorrect HOST header? HOT 1
- log4stash does not have Http compression for ES?
- Target Elasticsearch index is incorrect HOT 3
- Authentication configuration does not feel compatible with "log4net >= 2.0.8" HOT 2
- log4stach elastic search appender memory leak HOT 4
- Allowing self signed certs does not work (AllowSelfSignedServerCert) HOT 1
- Unobserved task exception in ASP.NET Web API project when using IndexAsync and BulkSize is reached during request
- In PrepareBulk: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
- Can't set authentication method v3.0.4 HOT 4
- IndexOperationParams from example is not working HOT 1
- How to use it on .Net 6? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log4stash.