Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a custom property to include in all log4net messages

I have a unique identifier which goes through the whole application. I want this 'ID' to be logged as a separate property, so that it's easy to find out in log files or from the database.

like image 203
Miral Avatar asked Jul 14 '10 09:07

Miral


1 Answers

You can use context properties e.g. like this:

ThreadContext.Properties["ID"] = yourID;

then you can access the property in the pattern string like this:

%property{ID}
like image 129
Stefan Egli Avatar answered Oct 11 '22 06:10

Stefan Egli