h2. Log Files
If you run into some issues while using RapidCMDB or other applications built on the RapidCMDB platform, such as RapidInsight, you can review the log files in the RS_HOME/RapidSuite/logs directory:
* RapidServer.log (RapidCMDB platform log messages)
* RapidServerErr.log (for stack trace information)
* Models.log (logging from model scripts)
Log level for these files can be changed by editing the RS_HOME/RapidSuite/grails-app/conf/Config.groovy. Following lines are where the levels are set:
{code}
// log4j configuration
log4j {
...
models="info,modelsLog"
grails="warn,rapidServerLog"
StackTrace="warn,errorLog"
...
}
{code}
Change the level, save the file and restart the server.
{info}
The log level can also be set at runtime with the help of a script. Get the logger you want to set the level (Logger.getRootLogger() or Logger.getLogger("models") and set its level by calling the setLevel method on it.
{info}
h2. Writing Log Messages From Consuming Scripts
It is a good practice to put log messages in your consuming scripts. A pre-configured logger is passed into the script (onDemand, scheduled, or listening scripts) with the name "logger". You can start printing log messages as shown below:
{noformat}
logger.info("Informational sample message");
logger.warn("More serious message for warning");
logger.debug("message for debugging");
{noformat}
{info}supported log levels are: off, fatal, error, warn, info, debug. off will not print any log messages while debug will print the most number of messages.
{info}
Log files for loggers are configured with the name of the script (name of the connector for Smarts listening connector) if the "Use Own Log File" property is selected. These messages will go into the RS_HOME/RapidSuite/logs/<Name of the script>.log file. If the "Use Own Log File" is unselected, the log messages will go to the RapidServer.log file. The *log level can be set dynamically* during runtime at the Scripts tab in the admin UI. You will see only the messages with the level equal to or greater than the level set.
{warning}
Updating a listening script will stop its execution. It needs to be restarted
{warning}
\\
\\
h2. Writing Log Messages From Model Scripts
You can and probably you should put log messages in your model scripts as well. There is a pre-configured "models" logger you can use for logging from your model scripts. In order to do so:
* make sure that Log4J is imported by inserting the following line in your script:
{noformat}
import org.apache.log4j.Logger
{noformat}
* get the "models" logger and print the log message at the desired level:
{noformat}
def log = org.apache.log4j.Logger.getLogger("models")
...
log.info("Informational sample message");
log.warn("More serious message for warning");
log.debug("message for debugging");
{noformat}
These messages will go into the RS_HOME/RapidSuite/logs/Models.log file. You will see only the messages with the level equal to or greater than the level set for the "models" logger in the Config.groovy as described in the previous section.
You can configure and use other loggers as well, please see the following "Log Configuration" section.
h2. Log Configuration
*Note:* RapidCMDB needs to be restarted after a log configuration change.
The loggers are configured in the RS_HOME/RapidSuite/grails-app/conf/*Config.groovy* file. See the log4j configuration section* \*
\\
{noformat}
...
log4j{
....
}
{noformat}
to see how the configuration can be changed. By editing this section, you can:
* change the log level (debug, info, warn, error)
* change the log appender (name of the file, rolling of the file, etc.)
* define a new logger with its new appender
h2.
If you run into some issues while using RapidCMDB or other applications built on the RapidCMDB platform, such as RapidInsight, you can review the log files in the RS_HOME/RapidSuite/logs directory:
* RapidServer.log (RapidCMDB platform log messages)
* RapidServerErr.log (for stack trace information)
* Models.log (logging from model scripts)
Log level for these files can be changed by editing the RS_HOME/RapidSuite/grails-app/conf/Config.groovy. Following lines are where the levels are set:
{code}
// log4j configuration
log4j {
...
models="info,modelsLog"
grails="warn,rapidServerLog"
StackTrace="warn,errorLog"
...
}
{code}
Change the level, save the file and restart the server.
{info}
The log level can also be set at runtime with the help of a script. Get the logger you want to set the level (Logger.getRootLogger() or Logger.getLogger("models") and set its level by calling the setLevel method on it.
{info}
h2. Writing Log Messages From Consuming Scripts
It is a good practice to put log messages in your consuming scripts. A pre-configured logger is passed into the script (onDemand, scheduled, or listening scripts) with the name "logger". You can start printing log messages as shown below:
{noformat}
logger.info("Informational sample message");
logger.warn("More serious message for warning");
logger.debug("message for debugging");
{noformat}
{info}supported log levels are: off, fatal, error, warn, info, debug. off will not print any log messages while debug will print the most number of messages.
{info}
Log files for loggers are configured with the name of the script (name of the connector for Smarts listening connector) if the "Use Own Log File" property is selected. These messages will go into the RS_HOME/RapidSuite/logs/<Name of the script>.log file. If the "Use Own Log File" is unselected, the log messages will go to the RapidServer.log file. The *log level can be set dynamically* during runtime at the Scripts tab in the admin UI. You will see only the messages with the level equal to or greater than the level set.
{warning}
Updating a listening script will stop its execution. It needs to be restarted
{warning}
\\
\\
h2. Writing Log Messages From Model Scripts
You can and probably you should put log messages in your model scripts as well. There is a pre-configured "models" logger you can use for logging from your model scripts. In order to do so:
* make sure that Log4J is imported by inserting the following line in your script:
{noformat}
import org.apache.log4j.Logger
{noformat}
* get the "models" logger and print the log message at the desired level:
{noformat}
def log = org.apache.log4j.Logger.getLogger("models")
...
log.info("Informational sample message");
log.warn("More serious message for warning");
log.debug("message for debugging");
{noformat}
These messages will go into the RS_HOME/RapidSuite/logs/Models.log file. You will see only the messages with the level equal to or greater than the level set for the "models" logger in the Config.groovy as described in the previous section.
You can configure and use other loggers as well, please see the following "Log Configuration" section.
h2. Log Configuration
*Note:* RapidCMDB needs to be restarted after a log configuration change.
The loggers are configured in the RS_HOME/RapidSuite/grails-app/conf/*Config.groovy* file. See the log4j configuration section* \*
\\
{noformat}
...
log4j{
....
}
{noformat}
to see how the configuration can be changed. By editing this section, you can:
* change the log level (debug, info, warn, error)
* change the log appender (name of the file, rolling of the file, etc.)
* define a new logger with its new appender
h2.