1
votes

Tried to add custom Logback pattern in order to log Exception stacktraces into a single line (where new line character is replaced with unicode Line separator \u2028), as:

%date{"yyyy-MM-dd'T'HH:mm:ss.SSSZ", UTC} %5p %t %c{5}:%L [log_framework=logback;app_name=${APP_NAME};app_version=${APP_VERSION};instance_id=${CF_INSTANCE_INDEX}] %m MULTIEXCEPTION %replace(%xException){'\n','\u2028'}%nopex%n 

Note: See spring-config.xml config file in Github

In the console, \n is replaced, the Exception stacktrace is in one line but, instead with "Line separator" character (\u2028), \n is replaced with the string "u2028".

If I try to log directly this "Line separator" character (via Logback, as log message) - it is printed in the console correctly.

What could be the problem?

1

1 Answers

2
votes

I've managed to do this by entering the "Line separator" unicode character (
) directly:

%date{"yyyy-MM-dd'T'HH:mm:ss.SSSZ", UTC} %5p %t %c{5}:%L [log_framework=logback;app_name=${APP_NAME};app_version=${APP_VERSION};instance_id=${CF_INSTANCE_INDEX}] %m MULTIEXCEPTION %replace(%xException){'\n','
'}%nopex%n 

Note: You can also manage to make Exception stacktraces "single-lined" in Spring Boot application by adding next application property:

logging.exception-conversion-word: "%replace(%xException){'\\n','\u2028'}%nopex"