1

I tried to redirect the log output only to a file, but Spring Boot stills logs in console. Is there any to disable console output?

I set into properties the file name but it does not solved.

###############
### Logging ###
###############
logging.level.=INFO
logging.file=log/${server.context-path}.log

Thanks any help!

Carlos Alberto
  • 7,761
  • 13
  • 52
  • 72
  • You can also override the base logback configuration: http://stackoverflow.com/a/30705668/2722134 – tiago Jun 22 '15 at 08:04

2 Answers2

2

According to spring boot doc, you need provide your own logging config file, logging.file will only additional log to file, here is the link: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html

Jaiwo99
  • 9,687
  • 3
  • 36
  • 53
0

I tried removing console configuration from logback.xml. But, It was still logging in console. So What I did is, I just removed the appender being added in the logging configuration by springboot. Thereby, we can stop springboot logging in console and separate log file. Add the below lines at the end of your application specific appenders are added. Your custom appender should not match any of these appender names. It worked for me.

// get instance of your log4j instance
Logger logger = LogManager.getRootLogger();
logger.removeAppender("CONSOLE"); // stops console logging
logger.removeAppender("LOGFILE"); // stops file logging
Kaliappan
  • 642
  • 9
  • 24