Reputation: 2863
I have been looking all over and was not able to figure this out. I need to add a custom log pattern for log output. I can do this very easily through a logback.xml file in the resources directory and it works exactly as I want it.
However, I would like to be able to do this throughout he application.yml file if that is possible. Mostly because I would like to externalize it in one place.
I have the normal logging stuff in application.yml as below:
#logging definitions
logging: file: logs/accountservice.log level: org: springframework: 'INFO' com: mangofactory: swagger: scanners: 'OFF' cisco: services: 'DEBUG'
The log pattern is like this:
Upvotes: 2
Views: 7203
Reputation: 48183
You can use logging.pattern.console
and logging.pattern.file
for customizing the log pattern to use on the console and file, respectively. For example, if you add this to your application.yml
:
logging:
pattern:
console: '%d{HH:mm:ss.SSS} %msg%n'
Your console logs would be like:
16:09:43.299 Log message
Checkout the Spring Boot documentation on Customizing log configuration for more information.
Upvotes: 4
Reputation: 8642
As of Spring Boot 1.2 it's not possible to customize the pattern using application.yml
. There is a feature request open to improve this (https://github.com/spring-projects/spring-boot/issues/1788).
Upvotes: 4