vy commented on code in PR #2691:
URL: https://github.com/apache/logging-log4j2/pull/2691#discussion_r1663019941


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java:
##########
@@ -188,23 +188,24 @@ private void formatOption(final Throwable throwable, 
final String suffix, final
         if (len > 0 && !Character.isWhitespace(buffer.charAt(len - 1))) {
             buffer.append(' ');
         }
-        if (!options.allLines() || nonStandardLineSeparator || 
Strings.isNotBlank(suffix)) {
-            final StringWriter w = new StringWriter();
-            throwable.printStackTrace(new PrintWriter(w));
-
-            final String[] array = w.toString().split(Strings.LINE_SEPARATOR);
-            final int limit = options.minLines(array.length) - 1;
-            final boolean suffixNotBlank = Strings.isNotBlank(suffix);
-            for (int i = 0; i <= limit; ++i) {
-                buffer.append(array[i]);
-                if (suffixNotBlank) {
-                    buffer.append(' ');
-                    buffer.append(suffix);
-                }
-                if (i < limit) {
-                    buffer.append(options.getSeparator());
+        if (requireAdditionalFormatting(suffix)) {
+            final StackTraceElement[] stackTrace = throwable.getStackTrace();
+            int ignoredCount = 0;

Review Comment:
   I agree with @alan0428a. We should avoid rolling out our own 
`printStackTrace()` wherever possible. There are several industry-wide 
assumptions on how a stack trace should look like (e.g., by [IBM Thread and 
Monitor Dump 
Analyzer](https://www.ibm.com/support/pages/ibm-thread-and-monitor-dump-analyzer-java-tmda))
 and I have witnessed in several occasions manually generated stack traces fail 
to match the structure of the `printStackTrace()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to