I have the following stringBuilder that I am using as part of Log4net log layout.
var sb = new StringBuilder(DateTime.Now.ToString(DateFormatString, CultureInfo.InvariantCulture));
sb.Append("\t");
sb.Append(log.EventAction);
sb.Append("\t");
sb.Append(log.Id);
sb.Append("\t");
sb.Append(log.MessageId);
sb.Append("\t");
sb.Append(log.CodeBlock);
sb.Append("\t");
sb.Append(log.Details);
I would expect the \t (tab) to give me an accurate tabbing as deliminator, so that when visually inspecting the text file, the columns would align. However this is not the case!
The columns are not aligning, and when I open up the text file in MS Word and "Display Special Characters", I see that the same tab entries seem to exist, but visually in notepad, columns don't align.
I'm really confused, maybe I need to review the definition of tab, can anyone provide insight or workaround to this issue?
Update:
I've noticed that if I have strings of identical length then the columns align, so for example:
string1(len5) TAB string2(len5) TAB string3(len5)
string1(len5) TAB string2(len5) TAB string3(len5)
string1(len5) TAB string2(len5) TAB string3(len5)
However if the strings differ in length, tab char is present, but strings don't align:
string1(len5) TAB string2(len5) TAB string3(len5)
string1(len10) TAB string2(len5) TAB string3(len5)
string1(len5) TAB string2(len5) TAB string3(len5)
string1(len10) TAB string2(len5) TAB string3(len5)
Something like this...