About the Logging subsystem
The Logging subsystem in the SGC Stack is based on the Simple Logging Facade for Java (SLF4J), which serves as a simple facade or abstraction for various logging frameworks, such as java.util.logging, logback, and log4j. SLF4J allows the end user to plug in the desired logging framework at deployment time. That said, the standard SGC Stack distribution uses SLF4J backed with the Apache Log4J logging architecture (version 1.x).
By default, the SGC stack outputs a minimal set of information, which will be used before the logging subsystem has been properly initialized, or when a severe error includes a logging subsystem malfunction. The default start-up script for the SGC stack redirects the standard output to SGC_HOME/logs/startup.<timestamp>
, where <timestamp>
denotes the SGC start time. This file is rolled over after reaching a size of 100
MB, with at most 10
backups.
SGC_HOME
SGC_HOME here represents the path to the SGC Stack installation directory.
|
Logger names, levels and appenders
Log4J logging architecture includes logger names, log levels, and log appenders.
Logger names
Subsystems within the SGC stack send log messages to specific loggers. For example, the alarming.log
logger receives messages about alarms being raised.
Examples of logger names include:
-
root
— the root logger, from which all loggers are derived (can be used to change the log level for all loggers at once) -
com.cts.ss7.SGCShutdownHook
— for log messages related to the SGC shutdown process -
com.cts.ss7.sccp.layer.scmg.SccpManagement
— for log messages related to incoming SCCP management messages.
Log levels
Log levels can be assigned to individual loggers to filter how much information the SGC produces:
Log level | Information sent |
---|---|
|
no messages sent to logs (not recommended) |
|
error messages for unrecoverable errors only (not recommended) |
|
error messages (not recommended) |
|
warning messages |
|
informational messages (the default) |
|
messages containing useful debugging information |
|
messages containing verbose debugging information |
Each log level will log all messages for that log level and above. For example, if a logger is set to the WARN
level, all of the log messages logged at the WARN
, ERROR
, and FATAL
levels will be logged as well.
If a logger is not assigned a log level, it inherits its parent’s. For example, if the com.cts.ss7.SGCShutdownHook
logger has not been assigned a log level, it will have the same effective log level as the com.cts.ss7
logger.
The root
logger is a special logger which is considered the parent of all other loggers. By default, the root
logger is configured with the DEBUG
log level, but the com
logger parent of all loggers used by SGC overwrites it to the WARN
log level. In this way, all other SGC loggers will output log messages at the WARN
log level or above unless explicitly configured otherwise.
Log appenders
Log appenders append log messages to destinations such as the console, a log file, socket, or Unix syslog daemon. At runtime, when SGC logs a message (as permitted by the log level of the associated logger), SGC sends the message to the log appender for writing. Types of log appenders include:
-
file appenders — which append messages to files (and may be rolling file appenders)
-
console appenders — which send messages to the standard out
-
custom appenders — which you configure to receive only messages for particular loggers.
Rolling file appenders
Typically, to manage disk usage, administrators are interested in sending log messages to a set of rolling files. They do this by setting up rolling file appenders which:
-
create new log files based on file size / daily / hourly
-
rename old log files as numbered backups
-
delete old logs when a certain number of them have been archived
You can configure the size and number of rolled-over log files. |
Default logging configuration
The default SGC Stack logging configuration is an XML file, in a format supported by Log4J, loaded during SGC startup. The default configuration is stored in SGC_HOME/config/log4j.xml
. The related DTD file is stored in SGC_HOME/config/log4j.dtd
.
For more information on Log4J and Log4J XML-based configuration, please see: |
Default appenders
The SGC Stack comes configured with the following appenders:
Appender | Where it sends messages | Logger name | Type of appender | ||
---|---|---|---|---|---|
|
the SGC logs directory ( |
|
a rolling file appender |
||
|
the SGC console where a node is running (to standard output stream)
|
|
a console appender |