0

Need help... what am I doing wrong here??? I believe it does read the path and file name from application.properties file. But I don't think it reads the logback.xml or logback-spring.xml

I did some research and found many questions/answers. But I think everyone says to put the logback xml in resources and give the path and file name in application.properties. I know it is simple, but missing something somewhere...

Thanks in advance!!

application.properties

# ===============================
# LOGGING
# ===============================
# log configuration -- update config location as needed
#logging.config=/logback-spring.xml
#logging.file=/logs/iqs-service.txt
logging.path=/logs
logging.file=${logging.path}/log.log
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n

enter image description here

enter image description here

Content of log file (log.log.0):

[2018-12-10 15:54:41.999] - 10828 INFO [main] --- org.apache.catalina.core.StandardService: Starting service Tomcat
[2018-12-10 15:54:42.002] - 10828 INFO [main] --- org.apache.catalina.core.StandardEngine: Starting Servlet Engine: Apache Tomcat/8.5.14
[2018-12-10 15:54:42.257] - 10828 INFO [localhost-startStop-1] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext
[2018-12-10 15:54:46.551] - 10828 INFO [http-nio-19917-exec-1] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring FrameworkServlet 'dispatcherServlet

Log statements in my java method - This never prints in the log

log.info("init(): [" + modelId + "]");
log.error("init(): [" + modelId + "]");

enter image description here

SK.
  • 1,390
  • 2
  • 28
  • 59

1 Answers1

0

As far as I can tell the only thing I think that will kill it are these lines:

logging.path=/logs
logging.file=${logging.path}/log.log

I believe that if you include both, Spring Boot will ignore both of them. So I'd try removing one of those, and seeing if that helps.

As another thing (but I don't think it contributes to this problem), Spring recommends that you have just a logback-spring.xml file, not logback.xml (and definitely not both).

Michael Coxon
  • 3,337
  • 8
  • 46
  • 68