[ https://issues.apache.org/jira/browse/LOG4J2-3154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17407241#comment-17407241 ]
Michael Cramer commented on LOG4J2-3154: ---------------------------------------- we considered and tried both: * maxStringLength: what we have seen is that mostly we "lost" the interesting part of the entire stack trace as the cause is at the end and truncation removes that part * stack trace truncation: the challenge or problem here is when we want to exclude all org.spring.. related parts which appear multiple times in a stack trace also in the middle of our code (caused by aspects and proxies) we "lose" everything afterwards  maybe as an idea (we are doing smth. similar for a different use-case) {code:java} private static final NameAbbreviator nameAbbreviator = NameAbbreviator.getAbbreviator("1."); public static String abbreviateStackTrace(@Nonnull final Throwable throwable) { final StringBuilder sb = new StringBuilder(); Arrays.stream(ExceptionUtils.getStackFrames(throwable)).forEach(line -> { // ExceptionUtils from commons-lang3 if (line.startsWith("\tat ")) { final String classNameDotMethod = line.substring("\tat ".length(), line.indexOf('(')); final int methodNameIndex = classNameDotMethod.lastIndexOf('.'); final String className = classNameDotMethod.substring(0, methodNameIndex); sb.append(line, 0, "\tat ".length()); nameAbbreviator.abbreviate(className, sb); sb.append(line.substring("\tat ".length() + methodNameIndex)); } else { sb.append(line); } sb.append(System.lineSeparator()); }); return sb.toString(); } {code} > Support NameAbbreviator in ExceptionResolver when using JsonTemplateLayout > -------------------------------------------------------------------------- > > Key: LOG4J2-3154 > URL: https://issues.apache.org/jira/browse/LOG4J2-3154 > Project: Log4j 2 > Issue Type: Improvement > Components: JsonTemplateLayout, Layouts > Affects Versions: 2.14.1 > Reporter: Michael Cramer > Priority: Major > Labels: abbreviation, exception, json, layout, resolver, template > > when stack traces are written to the JSON that is later consumed by Graylog > for example sometimes the processing failed because the field containing the > stack trace is larger than 32k which is a limit of the in ElasticSearch > ([https://github.com/Graylog2/graylog2-server/issues/873)] > I propose to add support for using the already existing NameAbbreviator to > shorten stack traces. it might not completely solve all issues that the field > might have content that is too large but tries to mitigate it. > {noformat} > { > "$resolver": "exception", > "field": "stackTrace", > "stackTrace": { > "stringified": true > } > } {noformat} > can be smth. like > {noformat} > { > "$resolver": "exception", > "field": "stackTrace", > "stackTrace": { > "stringified": true, > "abbreviatePattern": "1." > } > } {noformat} -- This message was sent by Atlassian Jira (v8.3.4#803005)