需要帮助......我在这里做错了什么???我相信它确实从 application.properties 文件中读取了路径和文件名。但我认为它不会读取 logback.xml 或 logback-spring.xml
我做了一些研究,发现了很多问题/答案。但是我想大家都说要把logback xml放到resources中,在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
日志文件的内容(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
在我的 java 方法中记录语句 - 这永远不会在日志中打印
log.info("init(): [" + modelId + "]");
log.error("init(): [" + modelId + "]");