By default Loki4j uses
JsonEncoder that converts log batches into JSON format specified by Loki API.
This encoder does not use any extra libs for JSON generation.
If you want to use
ProtobufEncoder, you need to add the following dependency to your project:
This library contains pre-generated encoders for Loki Protobuf format along with the proper version of Protobuf runtime and Snappy as a transitive dependencies.
Then you can explicitly specify
ProtobufEncoder by setting
class attribute for
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
Selecting a version of Protobuf
If you project already depends on a certain version of Protobuf, you will have to use a proper version of
loki-protobuf as well.
You can change the Protobuf version bundled with
loki-protobuf by modifying
The list of supported Protobuf versions is available in PB-VERSION file.
If the version you need is not listed in there, consider the following options:
Add the version you need to PB-VERSION file and create a PR to Loki4j. Once merged, this will add one more publishing configuration to
loki-protobuf, and the new Protobuf version will be available to everyone
.protofiles inside your project and generate corresponding Java files by yourself. This option is considered advanced, so you should be able to figure out all the details you might need from the
loki-protobuf's source code