In the ConversionPattern in a log4net config, is there a way to specify the thread number, even if it has a name?
e.g. something like the following: [7] ThreadFoo
It doesn't look like it's supported.
Based on the the PatternLayout Class documentation listing all the output options here the %thread
variable seems to wrap the behaviour you want to change.
You could possibly consider using Process ID instead? Depending on what your end objective is.
Have a look at this SO Answer, it would look like:
log4net.GlobalContext.Properties["pid"] = Process.GetCurrentProcess().Id;
and config usage
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%property{pid}" />
</layout>
you could add the thread id to the thread name:
Thread myThreadObj = new Thread(...);
myThreadObj.Name = "The thread name " + myThreadObj.ManagedThreadId;