Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
How to set logback.xml properties in application.yaml

I have logback.xml like this:

    <?xml version="1.0" encoding="UTF-8"?>
        <configuration scan="true" scanPeriod="2 seconds">

            <include resource="org/springframework/boot/logging/logback/base.xml"/>
            <jmxConfigurator/>

            <logger name="org.springframework" level="INFO"/>
            <logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="DEBUG"/>
            <logger name="com.mypackage" level="WARN"/>

            <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
                <encoder>
                    <pattern>
                        %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
                    </pattern>
                </encoder>
            </appender>

            <turboFilter class="ch.qos.logback.classic.turbo.DynamicThresholdFilter">
                <Key>dynamicLogLevel</Key>
                <DefaultThreshold>DEBUG</DefaultThreshold>
                <MDCValueLevelPair>
                    <value>dynamicLogLevelDEBUG</value>
                    <level>DEBUG</level>
                </MDCValueLevelPair>
                <!-- dynamicLogLevelERROR for testing -->
                <MDCValueLevelPair>
                    <value>dynamicLogLevelERROR</value>
                    <level>ERROR</level>
                </MDCValueLevelPair>
            </turboFilter>

 .....
</configuration>

I want to set the logger level, appenders , rolling policy present in logback.xml in application.yaml .

I have gone through this Doc but did not find sufficient info.

I'm using spring-boot 1.4.4-RELEASE.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The springProperty tag is probably all you need. Spring Boot will automatically filter the source properties in your configuration file and replace placeholders with the corresponding values from your properties.

<configuration scan="true" scanPeriod="2 seconds">
    <springProperty name="yourVar" source="key.of.your.yaml.property"/>

    ...${yourVar}...

You can see the details in the GitHub repository.

about 4 years ago · Santiago Trujillo Denunciar

0

I found the solution: My application.yaml in some folder(say C:/configuration/application.yaml, c:/configuration/logback.xml).

In logback.xml , we can access application.yaml contents using :

<property file="${HOME}/configuration/application.yaml"/>

for ex: in application.yaml

LOG_FILE : C:/logs

in logback.xml access it:

<appender name="MY_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}</file>

...

</appender>

But take care of value scanPeriod in

<configuration scan="true" scanPeriod="10 seconds">

Hope it will help.

about 4 years ago · Santiago Trujillo Denunciar

0

logging:
  level:
    org.springframework.web: ERROR
    com.pack.test: INFO
  pattern:
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
  file: <logPath>/test.log
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda