See Logging for an administrator description of logging.

Component Logging


Component logging provides the ability to output a message to a component-specific log file. All log files are written under the $ASPIRE_HOME/log directory. The actual path for the log file is constructed from the component path and name, such that a component /path/component will produce a log file $ASPIRE_HOME/log/path/component/component.log. Log files are rotated on a daily basis, or on a 10Mb size limit. Rotated log files receive a time stamp upon rotation.

Log messages may be output at a number of different levels depending on severity. These levels include:

  • debug
  • info
  • warning
  • error

Messages with raised severity debug will not be written to the components log file or kept locally unless a debug flag is set. This flag may be set in code or by way of the components XML configuration. Debug messages are never sent to the OSGI logger. Messages kept locally (for viewing by way of the Status page) are truncated to 200 characters.

Logging is built in to the component class and provides the following methods:

MethodDescription
public boolean debugging()Returns true if the debugging flag is set.
public void setDebug(boolean debug)Sets the debugging flag for this component.
public void debug(String fmt, Object ... args)Log a message with level DEBUG. If debugging is not set for this component, this message will not be written to the log file. This message will not be forwarded to the OSGI logger.
public void info(String fmt, Object ... args)Log a message with level INFO. This message will be forwarded to the OSGI logger.
public void warn(String fmt, Object ... args)Log a message with level WARN. This message will be forwarded to the OSGI logger.
public void warn(Throwable cause, String fmt, Object ... args)Log a message with level WARN reporting the given exception. This message will be forwarded to the OSGI logger.
public void error(String fmt, Object ... args)Log a message with level ERROR. This message will be forwarded to the OSGI logger.
public void error(Throwable cause, String fmt, Object ... args)Log a message with level ERROR reporting the given exception. This message will be forwarded to the OSGI logger.
public void log(LogLevel level, String fmt, Object ... args)Log a message with the given level. This message will be forwarded to the OSGI logger (except DEBUG).
public synchronized void log(LogLevel level, Throwable cause, String fmt, Object ... args)Log a message with the given level and exception. This message will be forwarded to the OSGI logger.
public synchronized void log(boolean noForwardToLogService, LogLevel level, Throwable cause, String fmt, Object ... args)Log a message with the given level and exception. This message will be forwarded to the OSGI logger (except DEBUG) if the noForwardToLogService flag is false.

Notes

  • The formats given in the fmt parameter are as per System.out.printf.
  • LogLevel is defined in com.searchtechnologies.aspire.framework.ALogWriter.LogLevel and consists DEBUG, INFO, WARN and ERROR.
  • See the Javadocs at https://wiki.searchtechnologies.com/javadoc/aspire-latest/ for more information.

 

  • No labels