简体   繁体   中英

lombok Log4j in spring boot

I work for a legacy spring boot project and they used @Log4j from lombok to display logs, but it seems that logging is disabled somewhere because no log is displayed.

Where I can verify if there is some configuration to disable logging.

This is an example for logging:

import lombok.extern.log4j.Log4j;
//........
@Log4j
public abstract class MyClassImpl implements MyClass{
    public String extractPNS(final String session, final String nomFichier, final String path, final String encoding) {
        MyClassImpl.log.debug("My class execution start...");
    }
}

There will be log folder inside your application . First check the config in any .properties file inside your application name

Have you checked log level? If it is set to INFO you won't be able to see DEBUG logs. It is configurable under *.properties or *.yml in src/main/resources . Also check for log4j.xml file which might be used co to configure Log4j .

I know this question is a bit old but I think it still needs an answer.

It is better to logging facade Slf4j instead of implementation specific log4j like this:

import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class MyClassImpl implements MyClass {
    public String extractPNS(final String session, final String nomFichier, 
       final String path, final String encoding) {
        log.info("My class execution start...");
    }
}

Then make sure you have a valid log4j config available in Spring Boot App's classpath somewhere that doesn't disable logging at info level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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