Resources
Overview
Training Center
Resource Center
Home > Resources > Training Center > Sample Project

Log Controller Sample

Description
Composite Information Server leverages the most popular logging framework for Java, Apache.s Log4J. Each of the loggers can be associated with a Log Level. Several log levels are defined, most commonly used are DEBUG and INFO. Within the code, there are instructions to send messages to the logger only if the log level is at or beyond a certain threshold. So for instance, if the log level is set to debug, both info and debug messages will be sent to the logger, while if the log level is set to info, only info messages will be sent while debug messages are ignored.

  • In normal operation, the loggers and their log levels are customized through the file apps/server/conf/log4j.properties. This file is read on startup and used to configure the log level of certain loggers. By default all the loggers are set to INFO. If you uncomment the line .log4j.logger.com.compositesw.server.qe=DEBUG. and restart the server the query engine logger will be set to log level DEBUG and debug messages from the query engine will be printed in the logs. Commenting the line again and restarting the server sets everything back to normal.
  • In order to modify the log level without restarting the server, however, you can install the Java Custom Procedure LogController. It is installed just like any custom java data source, and exposes several stored procedures to manipulate log levels at runtime.
  • The procedures ActivateLogger and DeactivateLogger allow one to turn on or off any log4j debugging for anything that is in the log4j.properties without cycling the server. The proc ToggleLogger just swaps the state of the logger from DEBUG to INFO and back. All these procedures will throw an exception if the logger does not exist. If you need to activate the logger before it is initialized the first time, you can use CreateLogger to create it, and then use ActivateLogger to activate it.
  • These tools will allow you to programmatically capture short bits of execution in the logs. For instance, you can create a script such as this:
    CALL /shared/sources/LogController/ActivateLogger('com.compositesw.server.qe');
    OPEN rs FOR SELECT * FROM /shared/view;
    CALL /shared/sources/LogController/DeactivateLogger('com.compositesw.server.qe'

Download

Disclaimer
Disclaimer of responsibility: This software is provided as-is; free of charge.