Official Plugin
Colotok provides several official plugins to extend its functionality for different use cases. This page describes each plugin, when to use it, and how to set it up.
colotok-coroutines
The colotok-coroutines plugin provides suspending logging extensions for use from coroutine contexts, as well as the AsyncProvider base class for batched providers.
Description: The extensions create the log record once and dispatch writes to the configured providers concurrently. For an AsyncProvider, they suspend until its channel accepts the record. A regular Provider keeps the same best-effort, non-blocking enqueue behavior as its synchronous write() method. Use AsyncProvider for a channel-backed, batched remote provider.
When to Use: Use this plugin when your application uses Kotlin coroutines and you want to:
Use suspending logging calls from coroutine code
Integrate logging with your coroutine-based application flow
Wait for channel capacity when writing to an
AsyncProvider
Setup: Add the dependency to your project:
Usage: The plugin provides async versions of all standard logging methods:
Platform Support: This plugin is published for the same targets as the core library: JVM, Android, JavaScript, iOS arm64, iOS Simulator arm64, and macOS arm64.
colotok-cloudwatch (JVM only)
The colotok-cloudwatch plugin provides integration with Amazon CloudWatch Logs, allowing you to send logs directly to AWS CloudWatch.
Description: This plugin enables sending logs to AWS CloudWatch Logs service, with support for different credential providers and buffered logging.
When to Use: Use this plugin when:
Your application runs on AWS infrastructure
You want to centralize logs in CloudWatch
You need to monitor logs across multiple instances
You want to leverage CloudWatch's log analysis features
Setup: Add the dependency to your project:
Usage: Configure the CloudWatch provider with your AWS credentials and log group/stream information:
Property | Description | Default |
|---|---|---|
| CloudWatch log group name |
|
| CloudWatch log stream name |
|
| CloudWatch credentials |
|
| Minimum log level to publish |
|
| Formatter used for CloudWatch event messages |
|
| Publish threshold; retained failures may grow to |
|
Buffering and Flushing: The CloudWatch provider buffers logs to improve performance. Publication is attempted when the buffer reaches the configured threshold (bufferSize), when you explicitly call flush(), and during graceful shutdown. After a failed attempt, the retained buffer is retried at later threshold multiples, at the retention limit, or on a flush.
Platform Support: This plugin is available for JVM platform only.
colotok-slf4j, colotok-slf4j2 (JVM only)
The colotok-slf4j and colotok-slf4j2 plugins allow Colotok to be used as an SLF4J backend.
Description: This plugin enables applications that use SLF4J for logging to use Colotok as the logging backend.
When to Use: Use this plugin when:
Your application or its dependencies use SLF4J for logging
You want to route SLF4J logs through Colotok
You need to integrate with existing code that uses SLF4J
Setup: Add the dependency to your project:
Each binding exposes its matching slf4j-api major as a transitive compile dependency. Do not add another API dependency unless you intentionally control the SLF4J version. Keep only one SLF4J provider/binding on the runtime classpath.
You'll also need to configure SLF4J to use Colotok as its implementation. This typically involves ensuring that the Colotok SLF4J binding is the only SLF4J implementation on the classpath.
Usage: Once configured, you can use SLF4J as normal, and the logs will be processed by Colotok:
Platform Support: This plugin is available for JVM platform only.
colotok-loki
The colotok-loki plugin provides integration with Grafana Loki, allowing you to send logs directly to a Loki server.
Description: This plugin enables sending logs to a Grafana Loki server using its HTTP API, with support for buffering and authentication.
When to Use: Use this plugin when:
You use Grafana for visualization and monitoring
You want to centralize logs in Loki
You need advanced log querying capabilities
You want to create dashboards and alerts based on log data
Setup: Add the dependency to your project:
Usage: Configure the Loki provider with your Loki server information:
Property | Description | Default |
|---|---|---|
| Loki host URL |
|
| Labels for Loki stream |
|
| Loki credentials |
|
| Minimum log level to publish |
|
| Formatter used for Loki values |
|
| Publish threshold; retained failures may grow to |
|
| Ktor HTTP client. The lazy default is provider-owned; an injected client is caller-owned | lazy |
Loki and CloudWatch use the timestamp captured by the original logging call, not the later publish time. Injected Loki clients are not closed by the provider; the caller must close them after provider shutdown.
Buffering and Flushing: The Loki provider buffers logs to improve performance. Publication is attempted when the buffer reaches the configured threshold (bufferSize), when you explicitly call flush(), and during graceful shutdown. After a failed attempt, the retained buffer is retried at later threshold multiples, at the retention limit, or on a flush.
Platform Support: This plugin is published for the same targets as the core library: JVM, Android, JavaScript, iOS arm64, iOS Simulator arm64, and macOS arm64.