SetThreadContextValue Method
The key or name to use for this variable.
The current value to assign to this variable for this thread.
Sets a context variable for this thread.
Syntax
'Declaration
Public Shared Sub SetThreadContextValue( _
ByVal _key_ As String, _
ByVal _value_ As String _
)
public static void SetThreadContextValue(
string _key_,
string _value_
)
Parameters
key
The key or name to use for this variable.
value
The current value to assign to this variable for this thread.
Remarks
This variable allows you to add contextual information to your log entries (like the session ID or username of the currently logged-in user, etc. This applies only when using manual configuration of LogManager through configuration file. In the
[%X{user} %X{session}] You can then set two thread context values for key "user" and key "session" and they will print out in the log file. For more information on configuring LogManager and defining appenders and layouts, please consult the user guide for your application. Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server familyRequirements
Reference