Domin0
Domin0

Reputation: 317

How to format stacktrace in log4j2 using special characters?

I'm trying to format stacktrace printed by Log4j2 so that the separator isn't the default new line but rather a tab (\t). I did basically what was advised here: How to format stacktrace in log4j2?

In the pattern I am able to use non-special characters, for example: %xwEx{separator(|)} will result in stack trace lines being separated by pipeline character.

However if I try this: %xwEx{separator(\t)} stacktrace lines aren't separated by a tab but a "\t" String like so:

java.lang.NullPointerException: error enovountered at ... \t at ... \t at ...

I tried using double backslash \\t but it didn't solve my problem. Is there a way to pass special characters like \t as the separator argument?

Upvotes: 3

Views: 869

Answers (1)

samabcde
samabcde

Reputation: 8114

Suppose you are using xml for configuration,

Referring to Represent space and tab in XML tag

Use 	 for tab.

%xwEx{separator(	)}

Upvotes: 2

Related Questions