Skip to content

Enabling log printing encountered NoSuchMethodError: org.slf4j.helpers.MessageFormatter.basicArrayFormat #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bytepoem opened this issue Apr 30, 2025 · 0 comments

Comments

@bytepoem
Copy link

Hello author, I'm here again! This time I encountered NoSuchMethodError when enabling SDK log printing.

My project dependency version:
springboot 2.7.18
slf4j-api 1.7.36
logback-core 1.2.12

sdk configuration code:

@Bean
public PaypalServerSdkClient paypalServerSdkClient() {
    PayPalProperties properties = paymentProperties.getPayPal();
    Environment environment = Environment.SANDBOX;
    if (!properties.getSandBox()) {
        environment = Environment.PRODUCTION;
    }
    PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
        .loggingConfig(builder -> builder
            .level(Level.DEBUG)
            .requestConfig(logConfigBuilder ->
                logConfigBuilder
                    .body(true)
            )
            .responseConfig(logConfigBuilder ->
                logConfigBuilder
                    .headers(true)
                    .body(true)
            )
        )
        .httpClientConfig(configBuilder ->
            configBuilder
                .timeout(10)
        )
        .clientCredentialsAuth(
            new ClientCredentialsAuthModel.Builder(
                properties.getClientId(),
                properties.getClientSecret()
            ).build()
        )
        .environment(environment)
        .build();
    log.debug("PayPal支付SDK初始化完成");
    log.debug("paypal config: {}", client);
    return client;
}

Error code:

Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.slf4j.helpers.MessageFormatter.basicArrayFormat(java.lang.String, java.lang.Object[])' 
at io.apimatic.core.logger.ConsoleLogger.log(ConsoleLogger.java:30) 
at io.apimatic.core.logger.SdkLogger.logRequest(SdkLogger.java:67) 
at io.apimatic.core.ApiCall.execute(ApiCall.java:74)
at com.paypal.sdk.controllers.OAuthAuthorizationController.requestToken(OAuthAuthorizationController.java:50)
at com.paypal.sdk.authentication.ClientCredentialsAuthManager.fetchToken(ClientCredentialsAuthManager.java:164)
at com.paypal.sdk.authentication.ClientCredentialsAuthManager.fetchToken(ClientCredentialsAuthManager.java:179)

This error will occur if I configure loggingConfig and enable log printing. I tried to upgrade slf4j-api to 2.0.10 (from the current repository, I saw that your version is this), and then run it again without any problem, but the upgrade of slf4j-api from 1.7.x to 2.x is a bit big, which has a certain impact on my project (such as dependency version conflict, log cannot be output). I would like to ask for any better suggestions on this?

At present, I plan to turn off log printing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant