0

I would like to set the log level info depending on the environment (develop, stage, prod), in a spring app. I tried creating different log4j.xml files and setting in the application.proopreties the configuration required for each env. For instance for stage I did logging.config=classpath:stage/log4j.xml, this in the application-stage.properties.

The program compiles correctly and the files are found. I have a different log level for each env. The problem is that I'm not seeing anything in the logs. I think Spring is using the file which is located in the classpath:log4j.xml path, because when I had a log4j.xml in this path the logs were printed with the level defined in it, and thereafter when I deleted this file, the app stoped to print the logs. I'm not pretty sure if is possible to configure this in the application.properties file and I need to do something different.

rasilvap
  • 1,771
  • 3
  • 31
  • 70
  • 1
    try moving log4j configs to application.properties only – DV Singh Dec 12 '20 at 04:53
  • A log4j 1 xml file will of course not configure log4j2. The name is different. lso if it is only levels you can do that from the `application.properties` instead of a seperate config. Just add `logging.level.root=DEBUG` or whatever you like to the environment specific application.properties. – M. Deinum Dec 12 '20 at 09:27

0 Answers0