Loki4j Logback

Loki4j Logback

  • Docs
  • Contributing
  • Help
  • GitHub

›Logback

Logback

  • Configuration
  • Labels and structured metadata
  • JSON Message Layout
  • Protobuf Support
  • Apache HttpClient
  • Grafana Cloud
  • Monitoring
  • Tracing
  • Migration Guide
  • Compatibility Matrix
  • Old Docs

Using Apache HttpClient

By default, Loki4j uses JavaHttpSender, backed by java.net.http.HttpClient. This sender does not require any extra dependencies. So, it should be a good fit for most users.

However, you may want to switch to ApacheHttpSender, backed by org.apache.http.client.HttpClient. In this case, you need to ensure you have added the required dependencies to your project:

Maven
Gradle
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
implementation 'org.apache.httpcomponents:httpclient:4.5.14'

Then you can explicitly specify ApacheHttpSender by setting class attribute for http section:

<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
    <http class="com.github.loki4j.logback.ApacheHttpSender">
        ...
    </http>
    ...
</appender>

ApacheHttpSender shares most of the settings with JavaHttpSender. However, there are some specific settings available only for ApacheHttpSender:

SettingDefaultDescription
http.maxConnections1Maximum number of HTTP connections to keep in the pool
http.connectionKeepAliveMs120000A duration of time in milliseconds in which the connection can be safely kept idle for later reuse. This value should not be greater than server.http-idle-timeout in your Loki config
← Protobuf SupportGrafana Cloud →
Loki4j Logback
Docs
Reference
Community
GitHubLinkedIn
More
Powered by Docusaurus
Copyright © 2020-2025 Anton Nekhaev and Contributors