Browse Source

Roll back to Log4j 2.24

This reverts:

 - 7a5e77fe67
 - 1590e4d2b3
 - 8cf0d17fbc

See gh-46334, gh-46372
pull/46938/head
Andy Wilkinson 4 months ago
parent
commit
50e5421467
  1. 3
      config/checkstyle/checkstyle-suppressions.xml
  2. 6
      core/spring-boot/build.gradle
  3. 8
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ElasticCommonSchemaStructuredLogFormatter.java
  4. 22
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverter.java
  5. 21
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Extractor.java
  6. 10
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatter.java
  7. 2
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/LogstashStructuredLogFormatter.java
  8. 2
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringProfileArbiter.java
  9. 4
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLogLayout.java
  10. 28
      core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverter.java
  11. 15
      core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ElasticCommonSchemaStructuredLogFormatterTests.java
  12. 4
      core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java
  13. 21
      core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatterTests.java
  14. 11
      core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/LogstashStructuredLogFormatterTests.java
  15. 4
      core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java
  16. 2
      core/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtractorTests.java
  17. 13
      platform/spring-boot-dependencies/build.gradle
  18. 10
      smoke-test/spring-boot-smoke-test-structured-logging-log4j2/src/main/java/smoketest/structuredlogging/log4j2/CustomStructuredLogFormatter.java

3
config/checkstyle/checkstyle-suppressions.xml

@ -75,7 +75,4 @@ @@ -75,7 +75,4 @@
<suppress files="ConditionMessage\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>
<suppress files="EntityManagerFactoryBuilder\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>
<suppress files="DockerApi\.java" checks="NoWhitespaceBefore" message="'...' is preceded with whitespace"/>
<!-- https://github.com/apache/logging-log4j2/issues/2769#issuecomment-3049020222 -->
<suppress files="SpringProfileArbiter\.java" checks="SpringMethodVisibility"/>
<suppress files="StructuredLogLayout\.java" checks="SpringMethodVisibility"/>
</suppressions>

6
core/spring-boot/build.gradle

@ -87,12 +87,6 @@ tasks.named("checkFormatMain") { @@ -87,12 +87,6 @@ tasks.named("checkFormatMain") {
source(fileTree("src/main/javaTemplates"))
}
tasks.named("compileJava") {
// Provide the project coordinates to the `GraalVmProcessor`:
options.compilerArgs << '-Alog4j.graalvm.groupId=org.springframework.boot'
options.compilerArgs << '-Alog4j.graalvm.artifactId=spring-boot-log4j'
}
plugins.withType(EclipsePlugin) {
eclipse {
synchronizationTasks syncJavaTemplates

8
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ElasticCommonSchemaStructuredLogFormatter.java

@ -19,11 +19,11 @@ package org.springframework.boot.logging.log4j2; @@ -19,11 +19,11 @@ package org.springframework.boot.logging.log4j2;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ThrowableProxy;
import org.apache.logging.log4j.core.time.Instant;
import org.apache.logging.log4j.util.ReadOnlyStringMap;
import org.jspecify.annotations.Nullable;
@ -71,10 +71,10 @@ class ElasticCommonSchemaStructuredLogFormatter extends JsonWriterStructuredLogF @@ -71,10 +71,10 @@ class ElasticCommonSchemaStructuredLogFormatter extends JsonWriterStructuredLogF
members.add("message", LogEvent::getMessage).as(StructuredMessage::get);
members.from(LogEvent::getContextData)
.usingPairs(contextPairs.nested(ElasticCommonSchemaStructuredLogFormatter::addContextDataPairs));
members.from(LogEvent::getThrown).whenNotNull().usingMembers((thrownProxyMembers) -> {
members.from(LogEvent::getThrownProxy).whenNotNull().usingMembers((thrownProxyMembers) -> {
thrownProxyMembers.add("error").usingMembers((error) -> {
error.add("type", Function.identity()).whenNotNull().as(ObjectUtils::nullSafeClassName);
error.add("message", Throwable::getMessage);
error.add("type", ThrowableProxy::getThrowable).whenNotNull().as(ObjectUtils::nullSafeClassName);
error.add("message", ThrowableProxy::getMessage);
error.add("stack_trace", extractor::stackTrace);
});
});

22
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverter.java

@ -21,7 +21,6 @@ import org.apache.logging.log4j.core.config.Configuration; @@ -21,7 +21,6 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.pattern.ConverterKeys;
import org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.PatternConverter;
import org.apache.logging.log4j.core.pattern.ThrowablePatternConverter;
import org.jspecify.annotations.Nullable;
@ -36,33 +35,24 @@ import org.jspecify.annotations.Nullable; @@ -36,33 +35,24 @@ import org.jspecify.annotations.Nullable;
*/
@Plugin(name = "ExtendedWhitespaceThrowablePatternConverter", category = PatternConverter.CATEGORY)
@ConverterKeys({ "xwEx", "xwThrowable", "xwException" })
public final class ExtendedWhitespaceThrowablePatternConverter extends LogEventPatternConverter {
public final class ExtendedWhitespaceThrowablePatternConverter extends ThrowablePatternConverter {
private final ExtendedThrowablePatternConverter delegate;
private final String separator;
@SuppressWarnings("deprecation") // https://github.com/apache/logging-log4j2/issues/3809
private ExtendedWhitespaceThrowablePatternConverter(Configuration configuration, @Nullable String[] options) {
super("WhitespaceExtendedThrowable", "throwable");
private ExtendedWhitespaceThrowablePatternConverter(Configuration configuration, String @Nullable [] options) {
super("WhitespaceExtendedThrowable", "throwable", options, configuration);
this.delegate = ExtendedThrowablePatternConverter.newInstance(configuration, options);
this.separator = this.delegate.getOptions().getSeparator();
}
@Override
public void format(LogEvent event, StringBuilder buffer) {
if (event.getThrown() != null) {
buffer.append(this.separator);
buffer.append(this.options.getSeparator());
this.delegate.format(event, buffer);
buffer.append(this.separator);
buffer.append(this.options.getSeparator());
}
}
@Override
public boolean handlesThrowable() {
return true;
}
/**
* Creates a new instance of the class. Required by Log4J2.
* @param configuration current configuration
@ -71,7 +61,7 @@ public final class ExtendedWhitespaceThrowablePatternConverter extends LogEventP @@ -71,7 +61,7 @@ public final class ExtendedWhitespaceThrowablePatternConverter extends LogEventP
* @return a new {@code WhitespaceThrowablePatternConverter}
*/
public static ExtendedWhitespaceThrowablePatternConverter newInstance(Configuration configuration,
@Nullable String[] options) {
String @Nullable [] options) {
return new ExtendedWhitespaceThrowablePatternConverter(configuration, options);
}

21
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Extractor.java

@ -16,14 +16,13 @@ @@ -16,14 +16,13 @@
package org.springframework.boot.logging.log4j2;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ThrowableProxy;
import org.jspecify.annotations.Nullable;
import org.slf4j.event.LoggingEvent;
import org.springframework.boot.logging.StackTracePrinter;
import org.springframework.util.Assert;
/**
* Functions to extract items from {@link LoggingEvent}.
@ -43,23 +42,19 @@ class Extractor { @@ -43,23 +42,19 @@ class Extractor {
}
@Nullable String stackTrace(LogEvent event) {
return stackTrace(event.getThrown());
return stackTrace(event.getThrownProxy());
}
@Nullable String stackTrace(@Nullable Throwable throwable) {
if (throwable == null) {
@Nullable String stackTrace(@Nullable ThrowableProxy throwableProxy) {
if (throwableProxy == null) {
return null;
}
if (this.stackTracePrinter != null) {
Throwable throwable = throwableProxy.getThrowable();
Assert.state(throwable != null, "Proxy must return Throwable in order to print exception");
return this.stackTracePrinter.printStackTraceToString(throwable);
}
return printStackTrace(throwable);
}
private static String printStackTrace(Throwable throwable) {
StringWriter stringWriter = new StringWriter();
throwable.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
return throwableProxy.getExtendedStackTraceAsString();
}
}

10
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatter.java

@ -98,8 +98,8 @@ class GraylogExtendedLogFormatStructuredLogFormatter extends JsonWriterStructure @@ -98,8 +98,8 @@ class GraylogExtendedLogFormatStructuredLogFormatter extends JsonWriterStructure
.usingPairs(contextPairs.flat(additionalFieldJoiner(),
GraylogExtendedLogFormatStructuredLogFormatter::addContextDataPairs));
members.add()
.whenNotNull(LogEvent::getThrown)
.usingMembers((thrownMembers) -> throwableMembers(thrownMembers, extractor));
.whenNotNull(LogEvent::getThrownProxy)
.usingMembers((thrownProxyMembers) -> throwableMembers(thrownProxyMembers, extractor));
}
private static String getMessageText(Message message) {
@ -131,9 +131,11 @@ class GraylogExtendedLogFormatStructuredLogFormatter extends JsonWriterStructure @@ -131,9 +131,11 @@ class GraylogExtendedLogFormatStructuredLogFormatter extends JsonWriterStructure
private static void throwableMembers(Members<LogEvent> members, Extractor extractor) {
members.add("full_message", extractor::messageAndStackTrace);
members.add("_error_type", LogEvent::getThrown).whenNotNull().as(ObjectUtils::nullSafeClassName);
members.add("_error_type", (event) -> event.getThrownProxy().getThrowable())
.whenNotNull()
.as(ObjectUtils::nullSafeClassName);
members.add("_error_stack_trace", extractor::stackTrace);
members.add("_error_message", (event) -> event.getThrown().getMessage());
members.add("_error_message", (event) -> event.getThrownProxy().getMessage());
}
private static void addContextDataPairs(ContextPairs.Pairs<ReadOnlyStringMap> contextPairs) {

2
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/LogstashStructuredLogFormatter.java

@ -68,7 +68,7 @@ class LogstashStructuredLogFormatter extends JsonWriterStructuredLogFormatter<Lo @@ -68,7 +68,7 @@ class LogstashStructuredLogFormatter extends JsonWriterStructuredLogFormatter<Lo
.whenNotNull()
.as(LogstashStructuredLogFormatter::getMarkers)
.whenNot(CollectionUtils::isEmpty);
members.add("stack_trace", LogEvent::getThrown).whenNotNull().as(extractor::stackTrace);
members.add("stack_trace", LogEvent::getThrownProxy).whenNotNull().as(extractor::stackTrace);
}
private static String asTimestamp(Instant instant) {

2
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringProfileArbiter.java

@ -90,7 +90,7 @@ final class SpringProfileArbiter implements Arbiter { @@ -90,7 +90,7 @@ final class SpringProfileArbiter implements Arbiter {
* @return this
* @see Profiles#of(String...)
*/
public Builder setName(String name) {
Builder setName(String name) {
this.name = name;
return this;
}

4
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/StructuredLogLayout.java

@ -87,12 +87,12 @@ final class StructuredLogLayout extends AbstractStringLayout { @@ -87,12 +87,12 @@ final class StructuredLogLayout extends AbstractStringLayout {
@SuppressWarnings("NullAway.Init")
private String charset = StandardCharsets.UTF_8.name();
public Builder setFormat(String format) {
Builder setFormat(String format) {
this.format = format;
return this;
}
public Builder setCharset(String charset) {
Builder setCharset(String charset) {
this.charset = charset;
return this;
}

28
core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverter.java

@ -20,8 +20,6 @@ import org.apache.logging.log4j.core.LogEvent; @@ -20,8 +20,6 @@ import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.pattern.ConverterKeys;
import org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.PatternConverter;
import org.apache.logging.log4j.core.pattern.ThrowablePatternConverter;
import org.jspecify.annotations.Nullable;
@ -35,33 +33,21 @@ import org.jspecify.annotations.Nullable; @@ -35,33 +33,21 @@ import org.jspecify.annotations.Nullable;
*/
@Plugin(name = "WhitespaceThrowablePatternConverter", category = PatternConverter.CATEGORY)
@ConverterKeys({ "wEx", "wThrowable", "wException" })
public final class WhitespaceThrowablePatternConverter extends LogEventPatternConverter {
public final class WhitespaceThrowablePatternConverter extends ThrowablePatternConverter {
private final ExtendedThrowablePatternConverter delegate;
private final String separator;
@SuppressWarnings("deprecation") // https://github.com/apache/logging-log4j2/issues/3809
private WhitespaceThrowablePatternConverter(Configuration configuration, @Nullable String[] options) {
super("WhitespaceThrowable", "throwable");
this.delegate = ExtendedThrowablePatternConverter.newInstance(configuration, options);
this.separator = this.delegate.getOptions().getSeparator();
private WhitespaceThrowablePatternConverter(Configuration configuration, String @Nullable [] options) {
super("WhitespaceThrowable", "throwable", options, configuration);
}
@Override
public void format(LogEvent event, StringBuilder buffer) {
if (event.getThrown() != null) {
buffer.append(this.separator);
this.delegate.format(event, buffer);
buffer.append(this.separator);
buffer.append(this.options.getSeparator());
super.format(event, buffer);
buffer.append(this.options.getSeparator());
}
}
@Override
public boolean handlesThrowable() {
return true;
}
/**
* Creates a new instance of the class. Required by Log4J2.
* @param configuration current configuration
@ -70,7 +56,7 @@ public final class WhitespaceThrowablePatternConverter extends LogEventPatternCo @@ -70,7 +56,7 @@ public final class WhitespaceThrowablePatternConverter extends LogEventPatternCo
* @return a new {@code WhitespaceThrowablePatternConverter}
*/
public static WhitespaceThrowablePatternConverter newInstance(Configuration configuration,
@Nullable String[] options) {
String @Nullable [] options) {
return new WhitespaceThrowablePatternConverter(configuration, options);
}

15
core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ElasticCommonSchemaStructuredLogFormatterTests.java

@ -101,14 +101,13 @@ class ElasticCommonSchemaStructuredLogFormatterTests extends AbstractStructuredL @@ -101,14 +101,13 @@ class ElasticCommonSchemaStructuredLogFormatterTests extends AbstractStructuredL
expectedError.put("message", "Boom");
assertThat(error).containsAllEntriesOf(expectedError);
String stackTrace = (String) error.get("stack_trace");
assertThat(stackTrace)
.startsWith(String.format("java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2."
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException"));
assertThat(json).contains(String
.format("java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2."
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException")
.replace("\n", "\\n")
.replace("\r", "\\r"));
assertThat(stackTrace).startsWith(
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
assertThat(json).contains(
"""
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
}
@Test

4
core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ExtendedWhitespaceThrowablePatternConverterTests.java

@ -19,7 +19,7 @@ package org.springframework.boot.logging.log4j2; @@ -19,7 +19,7 @@ package org.springframework.boot.logging.log4j2;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.ThrowablePatternConverter;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class ExtendedWhitespaceThrowablePatternConverterTests {
private final LogEventPatternConverter converter = ExtendedWhitespaceThrowablePatternConverter
private final ThrowablePatternConverter converter = ExtendedWhitespaceThrowablePatternConverter
.newInstance(new DefaultConfiguration(), new String[] {});
@Test

21
core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatterTests.java

@ -136,18 +136,21 @@ class GraylogExtendedLogFormatStructuredLogFormatterTests extends AbstractStruct @@ -136,18 +136,21 @@ class GraylogExtendedLogFormatStructuredLogFormatterTests extends AbstractStruct
String fullMessage = (String) deserialized.get("full_message");
String stackTrace = (String) deserialized.get("_error_stack_trace");
assertThat(fullMessage).startsWith(
"message\n\njava.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
.formatted());
"""
message
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
assertThat(stackTrace).startsWith(
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
assertThat(deserialized)
.containsAllEntriesOf(map("_error_type", "java.lang.RuntimeException", "_error_message", "Boom"));
assertThat(stackTrace).startsWith(
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
.formatted());
assertThat(json).contains(
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
.formatted()
.replace("\n", "\\n")
.replace("\r", "\\r"));
"""
message\\n\\njava.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
}
@Test

11
core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/LogstashStructuredLogFormatterTests.java

@ -80,13 +80,12 @@ class LogstashStructuredLogFormatterTests extends AbstractStructuredLoggingTests @@ -80,13 +80,12 @@ class LogstashStructuredLogFormatterTests extends AbstractStructuredLoggingTests
Map<String, Object> deserialized = deserialize(json);
String stackTrace = (String) deserialized.get("stack_trace");
assertThat(stackTrace).startsWith(
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
.formatted());
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
assertThat(json).contains(
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
.formatted()
.replace("\n", "\\n")
.replace("\r", "\\r"));
"""
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
}
@Test

4
core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/WhitespaceThrowablePatternConverterTests.java

@ -19,7 +19,7 @@ package org.springframework.boot.logging.log4j2; @@ -19,7 +19,7 @@ package org.springframework.boot.logging.log4j2;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.ThrowablePatternConverter;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class WhitespaceThrowablePatternConverterTests {
private final LogEventPatternConverter converter = WhitespaceThrowablePatternConverter
private final ThrowablePatternConverter converter = WhitespaceThrowablePatternConverter
.newInstance(new DefaultConfiguration(), new String[] {});
@Test

2
core/spring-boot/src/test/java/org/springframework/boot/logging/logback/ExtractorTests.java

@ -46,7 +46,7 @@ class ExtractorTests { @@ -46,7 +46,7 @@ class ExtractorTests {
}
@Test
void stackTraceWhenNoPrinterPrintsUsingFallback() {
void stackTraceWhenNoPrinterPrintsUsingLoggingSystem() {
Extractor extractor = new Extractor(null, createConverter());
assertThat(extractor.stackTrace(createEvent())).contains("java.lang.RuntimeException: Boom!");
}

13
platform/spring-boot-dependencies/build.gradle

@ -1252,14 +1252,23 @@ bom { @@ -1252,14 +1252,23 @@ bom {
releaseNotes("https://github.com/liquibase/liquibase/releases/tag/v{version}")
}
}
library("Log4j2", "2.25.1") {
library("Log4j2", "2.24.3") {
prohibit {
contains "-alpha"
contains "-beta"
because "we don't want alphas or betas"
}
group("org.apache.logging.log4j") {
bom("log4j-bom")
bom("log4j-bom") {
permit("biz.aQute.bnd:biz.aQute.bnd.annotation")
permit("com.github.spotbugs:spotbugs-annotations")
permit("org.apache.logging:logging-parent")
permit("org.apache.maven.plugin-tools:maven-plugin-annotations")
permit("org.jspecify:jspecify")
permit("org.osgi:org.osgi.annotation.bundle")
permit("org.osgi:org.osgi.annotation.versioning")
permit("org.osgi:osgi.annotation")
}
}
links {
site("https://logging.apache.org/log4j")

10
smoke-test/spring-boot-smoke-test-structured-logging-log4j2/src/main/java/smoketest/structuredlogging/log4j2/CustomStructuredLogFormatter.java

@ -16,10 +16,8 @@ @@ -16,10 +16,8 @@
package smoketest.structuredlogging.log4j2;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ThrowableProxy;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.logging.structured.StructuredLogFormatter;
@ -41,11 +39,9 @@ public class CustomStructuredLogFormatter implements StructuredLogFormatter<LogE @@ -41,11 +39,9 @@ public class CustomStructuredLogFormatter implements StructuredLogFormatter<LogE
result.append(" pid=").append(this.pid);
}
result.append(" msg=\"").append(event.getMessage().getFormattedMessage()).append('"');
Throwable throwable = event.getThrown();
ThrowableProxy throwable = event.getThrownProxy();
if (throwable != null) {
StringWriter stackTrace = new StringWriter();
throwable.printStackTrace(new PrintWriter(stackTrace));
result.append(" error=\"").append(stackTrace).append('"');
result.append(" error=\"").append(throwable.getExtendedStackTraceAsString()).append('"');
}
result.append('\n');
return result.toString();

Loading…
Cancel
Save