magnattic
magnattic

Reputation: 13018

log4net - Print specific property, not whole collection

Using log4net, I have saved custom information in the following way

ThreadContext.Properties["context"] = info;

How can I output only this specific property, using the PatternLayout?

If i use %property it prints the whole collection like this:

{log4net:HostName=wrkst16, context=[my stuff here]}

I only want the content of "context" itself though. I tried %properties['context'], but it just appends the ['context'] part:

{log4net:HostName=wrkst16, context=[my stuff here]}['context']

Any way to get only a specific item of the collection?

Upvotes: 1

Views: 203

Answers (1)

Stefan Egli
Stefan Egli

Reputation: 17028

This works:

%property{context}

Upvotes: 1

Related Questions