Richard
Richard

Reputation: 6116

Configuring Spring Boot Logback

I am trying to write the application.yml file with the logging configurations for spring boot. Thanks to Bal from my previous question I was able to take a look at the sample file on spring boot's website. Since I only want to configure the logging information for now here is what my yml file looks like right now:

# ===================================================================
# SPRING BOOT PROPERTIES
# ===================================================================


# LOGGING
logging:
  config: /logback.xml # Location of the logging configuration file. For instance `classpath:logback.xml` for Logback
  logging.level.org.springFramework=DEBUG # Log levels severity mapping. For instance `logging.level.org.springframework=DEBUG`
  path: # Location of the log file. For instance `/var/log`
  pattern:
    console: # Appender pattern for output to the console. Only supported with the default logback setup.
    file: # Appender pattern for output to the file. Only supported with the default logback setup.
    level: # Appender pattern for log level (default %5p). Only supported with the default logback setup.

But I have a few questions:

  1. How much logging configuration should I do here in the yml file versus the logback.xml file? Should any logging configuration be put here at all versus putting it all in logback.xml?
  2. Is the logging level configuration line written correctly?
  3. Can I use another library's logging level, like logback? For example, could I put this: ch.qos.logback.classic.Level=DEBUG

Upvotes: 1

Views: 1134

Answers (1)

sodik
sodik

Reputation: 4683

  1. I would not combine logback.xml with application.yml. Use either simplified configuration via application.yml if it is enough for you or use "fullfeatured" logback.xml.

To be honest I am not sure what will happen when you will have contradicting configuration in those two files (e.g. different patterns or log levels).

2 + 3. My guess is you have extra logging part. Correct example would be e.g.

logging:
  level:
    ch.qos.logback.classic: DEBUG
    org.hibernate: INFO

Upvotes: 1

Related Questions