1

I use Lombok @Log4j to logging in my class:

com.mypackage
import lombok.extern.log4j.Log4j;

@Log4j
public MyClass{
   public void myMethod(){
       MyClass.log.setLevel(Level.DEBUG);
     MyClass.log.error(MyClass.log.getLevel());

        MyClass.log.debug("TEST DEBUG LEVEL LOGGING");
   }
}

With this configuration I got only one logging :

2019-07-11 15:28:05.512 ERROR 15632 --- [nio-8080-exec-1] c.m.MyPackage  : null

I don't know if I missed somthing to configure my Lombok @Log4j logging level.

***** EDIT *****

I use SpringBoot and my application.properties have no peroperty related with logging level.

I already tried this properties but without result:

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR
medkhelifi
  • 1,071
  • 3
  • 17
  • 35
  • i don't think this is related to lombok, your application log level must me `ERROR` – Ryuzaki L Jul 11 '19 at 13:38
  • Yes I think so, But I don't know where to check my log4j level. – medkhelifi Jul 11 '19 at 13:39
  • web application? or spring application? there should be an `xml` file or look at properties file – Ryuzaki L Jul 11 '19 at 13:40
  • @Deadpool I use SpringBoot and my application.properties have no property related with logging level. – medkhelifi Jul 11 '19 at 13:41
  • try those answers – Ryuzaki L Jul 11 '19 at 13:42
  • @Deadpool I don't think that a duplication of [Spring Boot: How can I set the logging level with application.properties](https://stackoverflow.com/questions/20485059/spring-boot-how-can-i-set-the-logging-level-with-application-properties) Define spring.web log level didn't resolve my probleme. – medkhelifi Jul 12 '19 at 08:14
  • @medkhelifi You need to set the com.mypackage log level. Changes to the log level of Spring web will have no effect on the logging of your own packages. – Mark Rotteveel Jul 12 '19 at 14:34
  • @MarkRotteveel Yes thsi is what I did, thank you, Nenad gave us the answer. – medkhelifi Jul 12 '19 at 14:47

1 Answers1

3

If you don't have any existing logging configuration in your project, then SpringBoot uses logback by default and it has some sensible defaults. You can override them using application.properties (or application.yml), command line arguments or logback xml configuration file in your resources. It is nicely described here https://www.baeldung.com/spring-boot-logging

Nenad
  • 484
  • 3
  • 14
  • 1
    Thank you @Nenad, actually I just found the solution, I added `logging.level.com.mypackage=DEBUG` in my application.properties. – medkhelifi Jul 11 '19 at 14:06