Skip to content

Log Levels in Martini

Logging is a critical aspect of monitoring and diagnosing the behavior of applications. In Martini, log levels specify the severity of messages logged by the application. These levels help developers and system administrators control the volume and relevance of the information captured in the logs, enabling them to focus on important messages without being overwhelmed by data.

Martini supports a range of log levels that determine the priority of the messages to be logged. Each level corresponds to the importance of the message, and by configuring these levels, you can fine-tune your application’s logging to meet your operational needs. Below is a detailed explanation of each log level supported by Martini:

FATAL

The FATAL level designates very severe error events that will presumably lead the application to abort. This level is used when the system is in a critical state and is typically logged just before the application stops abruptly. It’s crucial to monitor these logs as they can indicate unrecoverable errors.

ERROR

The ERROR level indicates serious issues that require attention, representing errors that might allow the application to continue running but needs to be investigated and fixed promptly. This level is used to log exceptions that are handled and logged within a catch block.

WARN

WARN signals potentially harmful situations. This level is used for logging abnormal or undesired situations that are not necessarily errors but might warrant closer attention to prevent future issues. Warnings might highlight the use of deprecated APIs, poor use of resources, or unexpected states that do not stop the application but could potentially lead to errors or performance degradation.

INFO

The INFO level is used for messages that highlight the progress of the application at a coarse-grained level. This level provides insight into the application's operational flow, such as startup, shutdown, and major operations. INFO logs are generally informative in nature and do not imply any error or warning.

DEBUG

DEBUG provides detailed contextual information useful for debugging the application. This level is used to log detailed information on the flow through the system and state changes that are important for debugging but not necessarily of interest under normal circumstances. Debug logs are usually only enabled during development or troubleshooting.

TRACE

The TRACE level logs finer-grained informational events than the DEBUG level. This is the most verbose logging level (more detailed than DEBUG) and is used to log information about everything the application does. It's particularly useful for tracing the application behavior and understanding problems in great depth.

ALL

ALL is used to turn on all levels of logging. This level ensures that all messages of all severities are logged, providing a complete log trace but potentially generating a large amount of log data. This level is typically not recommended for production unless troubleshooting specific issues that require detailed logs.

Understanding and configuring the appropriate log level for your Martini application is essential for effective logging and monitoring. It ensures that you have access to the right level of detail when you need it, without cluttering your log files with unnecessary information.


Setting Log Levels in Martini Server Runtime

To effectively manage logging within your Runtime instance, you can adjust log levels both programmatically via the API or through the file system. This flexibility allows you to control log volume and focus on relevant information based on your operational requirements.

Via API Explorer: Log levels can be modified using the Martini API Explorer, a user-friendly interface designed for efficient interaction with the system's APIs. Follow these steps to set the log levels through the API Explorer:

  1. Access the API Explorer: Open a web browser and go to localhost:8080/api-explorer/ to access the API Explorer.

  2. Navigate to the System Tag: Locate and click on the System tag within the API Explorer to view various system configuration and operation endpoints.

  3. Configure Log Levels: Use the /esbapi/system/loggers endpoint found under the System tag to modify log levels for various components of your Martini application.

  4. Use POST to Set Log Levels: Set the desired log level by using the POST method at the /esbapi/system/loggers endpoint. Include a JSON payload with the logger's name and the desired log level, which can range from FATAL, ERROR, WARN, INFO, DEBUG, TRACE, to ALL.

Here is an example of how to format your JSON payload:

1
2
3
4
{
  "loggerName": "yourLoggerName",
  "logLevel": "INFO"
}

Via File System: Alternatively, log levels can also be adjusted directly in the file system by editing the log4j2.properties file. This method is particularly useful for environments where API access is restricted or during initial setup stages.

To modify log levels directly through the file system, follow these steps:

  1. Locate the Configuration File: Navigate to the /<martini-home>/conf/overrides directory on your server and locate the log4j2.properties file.

  2. Edit the Log Levels: Open the log4j2.properties file in a text editor. Find the lines corresponding to the loggers you wish to adjust. Log levels can be set by changing the value associated with each logger. For example, change logger.<id>.level = INFO to logger.<id>.level = DEBUG for more detailed logging.

  3. Save and Restart: After making the desired changes, save the file. It is essential to restart your Runtime instance to apply the new log level settings. This ensures that all components of the application use the updated logging configuration.

By following these steps, you can customize the logging behavior of your Martini Server Runtime to better suit your monitoring and debugging processes.