Skip to content

when I update log4j2's version to 2.24.2,I get a error #3284

@SweetWuXiaoMei

Description

@SweetWuXiaoMei

This is the log link:https://github.com/apache/servicecomb-java-chassis/actions/runs/12290867484/job/34298772628?pr=4640#step:5:4557
You can drag the page to the bottom。
the main error:

Error:  org.apache.servicecomb.core.invocation.timeout.PassingTimeStrategyTest.should_init_when_start_as_first_node_of_a_process_but_not_first_of_a_chain -- Time elapsed: 0.001 s <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.apache.servicecomb.core.tracing.TraceIdLogger
	at org.apache.servicecomb.core.Invocation.<init>(Invocation.java:107)
	at org.apache.servicecomb.core.invocation.timeout.PassingTimeStrategyTest.should_init_when_start_as_first_node_of_a_process_but_not_first_of_a_chain(PassingTimeStrategyTest.java:37)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NullPointerException [in thread "main"]
	at org.apache.logging.log4j.core.util.internal.InternalLoggerRegistry.computeIfAbsent(InternalLoggerRegistry.java:151)
	at org.apache.logging.log4j.core.LoggerContext.getLogger(LoggerContext.java:530)
	at org.apache.logging.log4j.core.LoggerContext.getLogger(LoggerContext.java:503)
	at org.apache.logging.log4j.core.LoggerContext.getLogger(LoggerContext.java:65)
	at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:49)
	at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:32)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:32)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
	at org.apache.servicecomb.core.tracing.TraceIdLogger.<clinit>(TraceIdLogger.java:26)
	at org.apache.servicecomb.core.Invocation.init(Invocation.java:131)
	at org.apache.servicecomb.core.Invocation.<init>(Invocation.java:123)
	at org.apache.servicecomb.core.TestInvocation.traceId_producerCreateTraceId(TestInvocation.java:209)

the main code:

public class TraceIdLogger {
  private static final Logger LOGGER = LoggerFactory.getLogger("scb-trace-id");

  private static final Marker MARKER = new ScbMarker();

  public static final String KEY_TRACE_ID = "SERVICECOMB_TRACE_ID";

  private final Invocation invocation;

  public TraceIdLogger(Invocation invocation) {
    this.invocation = invocation;
  }

  public Invocation getInvocation() {
    return invocation;
  }

  public static String constructSource(String source) {
    return "[" + source + "(" +
        Thread.currentThread().getStackTrace()[2].getLineNumber() + ")]";
  }

  public final String getName() {
    return invocation.getTraceId();
  }

  public void error(String format, Object... arguments) {
    MDC.put(KEY_TRACE_ID, getName());
    LOGGER.error(MARKER, format, arguments);
    MDC.remove(KEY_TRACE_ID);
  }

  public void warn(String format, Object... arguments) {
    MDC.put(KEY_TRACE_ID, getName());
    LOGGER.warn(MARKER, format, arguments);
    MDC.remove(KEY_TRACE_ID);
  }

  public void info(String format, Object... arguments) {
    MDC.put(KEY_TRACE_ID, getName());
    LOGGER.info(MARKER, format, arguments);
    MDC.remove(KEY_TRACE_ID);
  }

  public void debug(String format, Object... arguments) {
    MDC.put(KEY_TRACE_ID, getName());
    LOGGER.debug(MARKER, format, arguments);
    MDC.remove(KEY_TRACE_ID);
  }
}

the log4j.xml:

<Configuration status="INFO">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d][%t][%p][%c:%L] %m%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

It seems that getLogger execution failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions