RFR: 8271186: Add UL option to replace newline char [v6]
Ioi Lam
iklam at openjdk.java.net
Wed Aug 25 05:59:23 UTC 2021
On Wed, 25 Aug 2021 05:33:59 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:
>> Most of UL entries would print log in one line, however some categories (e.g. `exceptions`) have multiline entries as following:
>>
>>
>> [0.157s][info][exceptions] Exception <a 'java/lang/NullPointerException'{0x000000008b918f70}: test>
>> thrown in interpreter method <{method} {0x00007f8335000248} 'main' '([Ljava/lang/String;)V' in 'Test'>
>> at bci 9 for thread 0x00007f8330017160 (main)
>>
>>
>> It is ease to parse with log shipper (Fluent Bit, Logstash, and more) if UL can print all logs in one line.
>> Famous log shippers support multiline logs of course, but its configuration tends to be complex, and also some input plugins (e.g. TCP on Fluent Bit) do not support multiline logs.
>>
>> So I want to introduce new UL option `foldmultilines` to replace all of newline char (`\n`) in the log entry will be replaced to 2 chars `\\n`. In addition, all of backslashes (`\` in C) are also replaced to 2 chars `\\\`.
>>
>> After this patch, we can get following logs with `foldmultilines=true`:
>>
>>
>> [0.166s][info][exceptions] Exception <a 'java/lang/NullPointerException'{0x000000008b918f70}: test>\n thrown in interpreter method <{method} {0x00007fbc81000248} 'main' '([Ljava/lang/String;)V' in 'Test'>\n at bci 9 for thread 0x00007fbc9c0171a0 (main)
>>
>>
>> I've also filed [CSR](https://bugs.openjdk.java.net/browse/JDK-8271188) for this issue, please review it.
>
> Yasumasa Suenaga has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove initialize function from LogFileStreamOutput
LGTM. Just a small nit in the man page.
src/java.base/share/man/java.1 line 4426:
> 4424: .PP
> 4425: When \f[I]foldmultilines\f[R] is true, a log event that consists of multiple lines will be folded into a single line by replacing newline characters with the sequence '\\' and 'n' in the output. Existing single backslash characters will also be replaced with a sequence of two backslashes so that the conversion can be reversed. This option is safe to use with UTF-8 character encodings, but other encodings may not work. For example, it may happen inadvertently conversion in multi-byte sequences in Shift JIS and BIG5.
> 4426: This option is available only for file outputs.
How about: "For example, it may incorrectly convert multi-byte sequences in Shift JIS and BIG5."
-------------
Marked as reviewed by iklam (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/4885
More information about the hotspot-runtime-dev
mailing list