loki4j / loki-logback-appender

Fast and lightweight implementation of Logback appender for Grafana Loki
https://loki4j.github.io/loki-logback-appender/
BSD 2-Clause "Simplified" License
300 stars 26 forks source link

Spring context is not loading when Loki server is not accessible #133

Closed andrey-nakin closed 2 years ago

andrey-nakin commented 2 years ago

If my Loki server in unavailable (for any reason), the Spring Boot application does not start due to the following error:

Caused by: java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in com.github.loki4j.client.pipeline.DefaultPipeline@4d55f6d8 - Error while sending Batch #6f89cb4afb3d (8 291 bytes) to Loki (http://my.loki.server.net/loki/api/v1/push) java.net.ConnectException
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
...

Can it be more tolerate to the network errors that can be temporary?

nehaev commented 2 years ago

Hi @andrey-nakin, thanks for reporting!

Could you please provide the full stack trace for this IllegalStateException? Most likely it's caused by the real configuration issue.

The ERROR log line doesn't relate to IllegalStateException as it's just a log line. Log4j doesn't throw any exceptions in case sending failed, only writes an error to log. You can check the corresponding code here: https://github.com/loki4j/loki-logback-appender/blob/main/loki-client/src/main/java/com/github/loki4j/client/pipeline/DefaultPipeline.java#L269

nehaev commented 2 years ago

Feel free to re-open with more details if my understanding is incorrect