2

I have a Spring Framework application and I am migrating it to Spring Boot. How to configure it in such a way that it can create log for each day?

This is my logging configuration so far:

logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
kryger
  • 12,906
  • 8
  • 44
  • 65
Om Komawar
  • 251
  • 3
  • 19
  • 1
    look [here](http://stackoverflow.com/questions/29918323/how-to-configure-rolling-file-appender-within-spring-boots-application-yml) – bilak Sep 26 '16 at 14:21
  • I don't think Spring Boot provides such a facility via it's configuration. You'll probably have to stick with your logging framework's facilities – geoand Sep 26 '16 at 14:22
  • You should be able to reuse whatever logging configuration you already have (and this would be more relevant to the question than the `logging.level` properties you decided to include) – kryger Sep 26 '16 at 14:39
  • The package level logging and log archival are defined by framework specific configuration file. For log4j2 library, this is would be defined in log4j2.xml. Pls check log4j documentation for an example. – Srikanta Sep 26 '16 at 14:58

1 Answers1

5

From the docs

Spring boot will use Logback if its in the classpath. If you put a logback.xml in the root of your classpath it will be picked up from there automatically.

You can customize this logback.xml to provide your configurations for adding a rolling appender and so on based on your requirement. The documentation and the examples here will help you.

Update

You can even use log4j2 for logging. Just ensure that the correct dependencies are included. In that case, spring boot will check if there is a log4j2.xml in the classpath. You can provide the required configurations using log4j2.xml.

Michael Lihs
  • 7,460
  • 17
  • 52
  • 85
ameenhere
  • 2,203
  • 21
  • 36