I'm using log4net, and when i log messages my threadID will be duplicated inside my file.. i want it to be a uniqueID whereby it never exists twice in the file so that it will make it easy for searching. I hope this is coming out right. basically my conversion pattern includes these items
<conversionPattern value="%date [%hex_thread] %method %-5level %logger – %message%newline"/>
And this is my output:
2010-07-08 11:12:32,426 [B] methodC INFO methodC – inside method C
2010-07-08 11:12:58,316 [B] methodC INFO methodC – inside method C
2010-07-08 11:13:09,284 [A] methodC INFO methodC – inside method C
2010-07-08 11:15:04,214 [B] methodC INFO methodC – inside method C
where hex_thread is my threadID in hexadecimal. You can see that [B] occurred several times and it shouldn't since the execution time is different. So, I want to make it also unique. so that its something that doesn't occur any where in that line. like maybe "0b87007" something like this which if I search it will be the only occurrence in that whole line. How can I achieve this?
Edited To add My Fix
My threadId is printed in hex format so i just appending several characters to the output like this....
long id = System.Threading.Thread.CurrentThread.GetHashCode(); String str = id.ToString("X"); writer.Write("0x0000"+str);
Then the output would look like this
2010-07-09 10:07:37,917 [0x00004] methodC INFO methodC – message
2010-07-09 10:07:37,917 [0x0000B] methodC INFO methodC – message