kotlin-logging OpenTracing Decorator
Small library on top of kotlin-logging which writes OpenTracing logs in addition to regular logs, by the means of a decorator.
In an application with a tracer registered in GlobalTracer, extend your regular logger instance with OpenTracing logs:
val logger = KotlinLogging.logger {}.withOpenTracingLogs()
Alternatively you instantiate an identical logger as such:
val logger = Logging.logger {}
You can now use the logger
as before as it still implements the KLogger interfaces. Hence, if you are already using kotlin-logging, you do not need to make any further changes to your application.
From Maven Central.
Add the following dependency to your pom.xml
:
<dependency>
<groupId>com.github.fstien</groupId>
<artifactId>kotlin-logging-opentracing-decorator</artifactId>
<version>VERSION_NUMBER</version>
<type>pom</type>
</dependency>
Add the following to your dependencies in your build.gradle
:
implementation 'com.github.fstien:kotlin-logging-opentracing-decorator:VERSION_NUMBER'
For use in a Ktor application, see kotlin-logging-opentracing-decorator-example.