Package org.kaaproject.kaa.client.logging

Provides log collection stuff.

See: Description

Package org.kaaproject.kaa.client.logging Description

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"
          }
    ]
 }
 
 
Add new log record
 // 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);
 
 
Logging components

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.