Previous Topic

Next Topic

Book Contents

Book Index

Log Grouping

General Idea

The OSGi logging service provides logging facilities and a mechanism to forward application logs to files. There is a default log group, in which all the logs are written. However, writing all logs to a single file or a group of files according to the maximum file size can make navigating through logs a bit difficult, with viewing so much mixed data. To make searching for logs a lot easier, a new feature is added:

Definitions

For the purposes of separating the output to multiple log files, a concept of log grouping is introduced using the following definitions:

log.group.name=<group_name>   # Name of the group - required.

log.dir=<folder_path>   # the folder in which log files will be stored, relative to bin/vms/jdk - required.

log.file.base=<file_name>   # the file name of the logging file - required.

bundle.symbolicNames=<list_of_bundles>   # a comma-separated list of bundle names in the group - required. A suffix wildcard ('*') is supported to include multiple bundles.

Enable/Disable Default Log Grouping

The default log group behavior can be disabled by setting the system property mbs.log.appender.default.strict to true – in this case all logs are forwarded to the group of their bundles.

Some bundles may remain outside any group and even outside the default one, when the system property is set to true, and some bundles may be in multiple groups.

Configurations

Default Log Group Configuration

The default log group is configured by mbs.log.FileLogAppender.Default PID.

The following configuration properties are supported:

Custom Log Groups Configuration

Each log group is configured separately using mbs.log.FileLogAppender.<group_name> as PID and com.prosyst.mbs.impl.services.log.FileLogAppender as factory PID in two ways:

#version=2.0

enabled:boolean=true

timeThreshold:int=10

Samples

# OSGi specification bundles

log.group.name=osgi

log.dir=logs

log.file.base=osgi

bundle.symbolicNames=com.prosyst.mbs.osgi.*

 

# Bosch IoT Core bundles

log.group.name=core

log.dir=logs

log.file.base=core

bundle.symbolicNames=com.prosyst.mbs.core.*

 

# HDM bundles

log.group.name=hdm

log.dir=logs/hdm

log.file.base=hdm

bundle.symbolicNames=com.prosyst.mbs.hdm.*

 

# Bosch specific bundles

log.group.name=bosch

log.dir=logs/bosch

log.file.base=bosch

bundle.symbolicNames=de.bosch.*, com.bosch.*