简体   繁体   English

如何关闭 log4j 日志记录

[英]How to turn off log4j logging

I work on my Spring Boot app which uses Spring API client as a maven depencency.我在我的 Spring 启动应用程序上工作,它使用 Spring API 客户端作为 Z402C5D9AF6B43711EA070BEEDZ70 客户端。 When I use it in my code, it logs data.当我在我的代码中使用它时,它会记录数据。 How can I turn it off?我怎样才能关闭它? Where shall I place log4j.properties to actually work?我应该将 log4j.properties 放在哪里才能实际工作? I tried inside resources and also inside folder with my service which uses it.我尝试了内部资源以及使用它的服务的文件夹内部。

package com.example.demo.service;

import com.wrapper.spotify.SpotifyApi;
import com.wrapper.spotify.SpotifyHttpManager;
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
import com.wrapper.spotify.model_objects.credentials.AuthorizationCodeCredentials;
import com.wrapper.spotify.requests.authorization.authorization_code.AuthorizationCodeRequest;
import org.apache.hc.core5.http.ParseException;



import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;


public class AuthorizationCodeExample {
    private static final String clientId = "";
    private static final String clientSecret = "";
    private static final URI redirectUri = SpotifyHttpManager.makeUri("");
    private static final String code = "";

    private static final SpotifyApi spotifyApi = new SpotifyApi.Builder()
            .setClientId(clientId)
            .setClientSecret(clientSecret)
            .setRedirectUri(redirectUri)
            .build();
    private static final AuthorizationCodeRequest authorizationCodeRequest = spotifyApi.authorizationCode(code)
            .build();

    public static void authorizationCode_Sync() {
        try {
            final AuthorizationCodeCredentials authorizationCodeCredentials = authorizationCodeRequest.execute();

            // Set access and refresh token for further "spotifyApi" object usage
            spotifyApi.setAccessToken(authorizationCodeCredentials.getAccessToken());
            spotifyApi.setRefreshToken(authorizationCodeCredentials.getRefreshToken());

            System.out.println("Expires in: " + authorizationCodeCredentials.getExpiresIn());
        } catch (IOException | SpotifyWebApiException | ParseException e) {
            System.out.println("Error: " + e.getMessage());
        }
    }


    public static void main(String[] args) {

        authorizationCode_Sync();
    }
}

This is my project tree: https://imgur.com/mS676gw这是我的项目树: https://imgur.com/mS676gw

logging.level.*=LEVEL

There are different levels available, the one you are looking for is OFF.有不同的级别可用,您要查找的级别为 OFF。 So just add the following line into your application.properties file所以只需将以下行添加到您的 application.properties 文件中

logging.level.*=OFF

It should be resources folder.它应该是资源文件夹。 But did you made changes inside the file to turn off logs?但是您是否在文件内部进行了更改以关闭日志? log4j.rootLogger=OFF, Note that this has the highest priority and will turn off all logging. log4j.rootLogger=OFF,注意这个优先级最高,会关闭所有日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM