
dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-logging/artifactId /dependency在src/main/resources目录下创建一个名为logback-spring.xml的配置文件Spring Boot会默认加载这个配置文件。Spring Boot官方推荐优先使用带有-spring的文件名作为日志配置?xml version1.0encodingUTF-8?configuration!--Spring Boot 启动时会自动把 logging.file.path 绑定到LOG_PATH变量,如果未指定就用默认的 windows的临时路径%TEMP%--include resourceorg/springframework/boot/logging/logback/base.xml/logger nameorg.springframework.weblevelINFO/logger nameorg.springboot.samplelevelTRACE/!--开发、测试环境--springProfile namedev,testlogger nameorg.springframework.weblevelINFO/logger nameorg.springboot.samplelevelINFO/logger namecom.**.**levelDEBUG//springProfile!--生产环境--springProfile nameprodlogger nameorg.springframework.weblevelERROR/logger nameorg.springboot.samplelevelERROR/logger name包目录结构levelERROR//springProfile/configuration