3

I'm building a spring boot application. I use logstash to create structured logs, and this works great. However, I'm trying to move the following logback.xml to application.yml.

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder" />
    </appender>

    <root level="info">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

I can't find any tutorial or example that comes remotely close to getting this in application.yml.

furthermore I noticed the following. If I remove logback.xml and put the following in application.yml

spring:
  logging:
    level:
      ROOT: WARNING

According to this question, I should at least have control over my log level. No dice, info's getting logged all over the place.

So, questions:

  • How do I specify the ROOT log level properly in application.yml?
  • How do I specify logstash encoder properly in application.yml?
hasdrubal
  • 1,024
  • 14
  • 30

1 Answers1

3

Root level can be configured like this:

logging:
  level:
    root: warning

But the encoder cannot be configured using properties or yaml. Please find all properties in the Spring Boot Reference Doc: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties

So there is no way around the logback xml file

Simon Martinelli
  • 34,053
  • 5
  • 48
  • 82