Logging and configuration
For Java plug-ins, the plug-in's constructor is passed a configuration object, the chain name and a logger object. The Abstract classes supplied store these as members (the logger object is named logger).
For C++ plug-ins, the Abstract classes have a logger member with methods to log at log levels from TRACE to CRIT, with a printf format and variadic arguments. Expensive computations can be predicated on a check of is<Level>Enabled().
Plug-ins should use the SLF4J
logger object provided for logging. You should avoid using
System.out or
System.err for logging. For both plug-ins written in C++ and Java, log messages are prefixed with
connectivity.PluginName.ChainName, which is also the category to configure log levels using the
correlatorLogging section in the YAML configuration file (see
Setting correlator and plug-in log files and log levels in a YAML
configuration file). This means, it is not required to identify the plug-in or chain in every log statement.
If your plug-in uses a third-party library that logs with SLF4J or Log4j 2, then the log output goes to the main correlator log file automatically. You can customize log levels as needed using
correlatorLogging in the YAML configuration file (see
Setting correlator and plug-in log files and log levels in a YAML
configuration file). When using a library which uses some other logging implementation, such as Log4j 1, the JDK logger, or Apache Java commons logging (JCL), then add a bridging jar to convert it to SLF4J where possible. Several bridges are available in the
common/lib/ext and
common/lib/ext/log4j directories of your Software AG installation.
The configuration contains the definitions from the configuration file for connectivity plug-ins (any globalConfig is merged with the per-chain configuration so that the per-chain configuration takes precedence). The configuration is a map with String keys. The values will be one of the following classes:
List<Object> (for C++,
data_t of type
list_t) for list YAML entries. Each element will be one of these types.
Map<String, Object> (for C++,
data_t of type
map_t) for map YAML entries. Each value will be one of these types.
String (for C++,
data_t of type
const char *). Even if the entry in the configuration file is numeric or a boolean, it will be provided as a string.
Plug-ins should use the MapExtractor class to extract values from the configuration map which makes it easy to check for invalid configuration options and produce helpful error messages if a required value is missing or of the wrong type.
You can also use the Diagnostic codec to diagnose issues with connectivity plug-ins. See
The Diagnostic codec connectivity plug-in for further information.