Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

679
Visualizações
Logging to file using docker and logback

I use logback for logging. logback.xml:

<configuration>
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>logs/test.log</file>
        <append>true</append>
        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

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

    <root level="DEBUG">
        <appender-ref ref="FILE" />
    </root>
</configuration>

Without docker everything works fine, but with docker log file is not created. How i can see logs using docker?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Do you have specified in docker file the creation about /log/test.log file? I think the problem is the path that is not created in docker.

over 4 years ago · Santiago Trujillo Relatório

0

If you log to console (not file) then you will be able to view the logs using the 'docker logs' command. Generally, logging to file in docker is not of much use as the file will disappear with the container.

over 4 years ago · Santiago Trujillo Relatório

0

I know this is really late, but it might help someone like me in future:

The solution is to add a volume in the docker-compose.yml file, to have a place with write permission.

in docker-compose file:

volumes:
    - ${PWD}/log:/log

in application.yml:

logging:
    file:
       name: ./log/saps.log
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda