Interface | Description |
---|---|
AccessPointCommand | |
GenericLogCollector |
Root interface for a log collector.
|
LogCollector |
Interface for a log collector.
|
LogFailoverCommand | |
LogProcessor |
Processes the Logging requests and responses.
|
LogStorage |
Interface for log storage.
|
LogStorageStatus |
Interface for a log storage status.
|
LogUploadStrategy |
Interface for log upload strategy.
|
Class | Description |
---|---|
AbstractLogCollector |
Reference implementation of @see LogCollector
|
DefaultLogCollector |
Reference implementation of @see LogCollector
|
DefaultLogUploadStrategy |
Reference implementation for
LogUploadStrategy . |
LogBlock |
Wrapper class for a log block which is going to be sent.
|
LogRecord |
Wrapper class to encapsulate Avro-generated log record.
|
MemoryLogStorage |
Reference implementation for
LogStorage and LogStorageStatus |
Enum | Description |
---|---|
LogUploadStrategyDecision |
Describes all possible decisions for a log upload strategy (
LogUploadStrategy ). |
Provides log collection stuff.
The Kaa Logging subsystem is designed to collect records (logs) of pre-configured structure, periodically deliver them from endpoints to Operation servers, and persist in the server for further processing, or submit to immediate stream analytics.
The Kaa logs structure is determined by the schema that is configurable.
Assume, log record schema has the following form:
{
"type": "record",
"name": "LogData",
"namespace": "org.kaaproject.sample",
"fields": [
{
"name": "level",
"type": {
"type": "enum",
"name": "Level",
"symbols": [
"DEBUG",
"ERROR",
"FATAL",
"INFO",
"TRACE",
"WARN"
]
}
},
{
"name": "tag",
"type": "string"
},
{
"name": "message",
"type": "string"
}
]
}
// Get a Log Collector reference
LogCollector logCollector = Kaa.getKaaClient().getLogCollector();
// Create a log entity (according to the org.kaaproject.sample.LogData sample schema above)
LogData logRecord = new LogData(Level.INFO, "tag", "message");
// Push record to collector
logCollector.addLogRecord(logRecord);
Kaa SDK logging stuff is based on three main components - log storage
(LogStorage
,
LogStorageStatus
), upload strategy
(LogUploadStrategy
) and configuration
(org.kaaproject.kaa.client.logging.LogUploadConfiguration
). For each
of these components there is a reference implementation using by defaults
(MemoryLogStorage
,
DefaultLogUploadStrategy
,
org.kaaproject.kaa.client.logging.DefaultLogUploadConfiguration
correspondingly).
The log storage is responsible for a log persistence.The reference implementation stores all added logs in a dynamic memory, so if there are some logs but application has been closed immediately or crashes, logs will be lost.
The log upload strategy is used to decide what Kaa should do after each
log record is added (LogUploadStrategyDecision
).
The configuration is used to define all limitations that affects
on a log collection stuff. The reference implementation works with three
parameters: batch volume (8KB), threshold volume (32KB) and maximum allowed
volume (1MB). More details about them see in
org.kaaproject.kaa.client.logging.LogUploadConfiguration
.
If there are need in some specific triggers for upload or you want to use
more reliable storage, simply set your own implementation for interested
component (GenericLogCollector.setStorage(LogStorage)
,
org.kaaproject.kaa.client.logging.LogCollector#setStorageStatus(LogStorageStatus)
,
GenericLogCollector.setStrategy(LogUploadStrategy)
,
org.kaaproject.kaa.client.logging.LogCollector#setConfiguration(LogUploadConfiguration)
).
Copyright © 2015. All rights reserved.