Log settings

All FortifiedID products rely on logging based on Log4j2. Adjusting the default log settings can be desirable for specific use cases. By default, these settings are managed through the log4j2.xml conf

log4j2.xml - where is it found

Pattern for FortifiedID products are the same. Default file is found under <install_root>/application/config.

When installing installer will redirect so log4j2.xml should be found at

<install_root>/customer/config.

Log levels

Generic levels is

INFO – The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.

WARN – The WARN level designates potentially harmful situations.

ERROR – The ERROR level designates error events that might still allow the application to continue running.

DEBUG – The DEBUG Level designates fine-grained informational events that are most useful to debug an application.

TRACE – The TRACE Level designates finer-grained informational events than the DEBUG

For more fine-tuned loggin on separate parts of the system it can be useful not setting TRACE on everything. See examples below.

Log files

By default, log files are stored in <install_root>/customer/logs, regardless of whether the environment is Linux or Windows. Two main log files are generated:

server.log: Contains system information, primarily used for monitoring server status and troubleshooting.

event.log: Records event-specific information, such as user logins, password resets, and similar activities.

Both logs are configured to “roll” daily by default, but this setting can be adjusted to roll more frequently or based on file size, depending on requirements.

Example

Settings PIPES to DEBUG but keep the rest at default:

<AsyncLogger name="foss.pipes" level="DEBUG" />

Settings HTTP module to DEBUG but keep the rest at default:

<AsyncLogger name="foss.platform.modules.http" level="DEBUG" />

Settings LDAP module to DEBUG but keep the rest at default:

<AsyncLogger name="foss.platform.modules.ldap" level="DEBUG" />

Settings SMTP module to DEBUG but keep the rest at default:

<AsyncLogger name="foss.platform.modules.smtp" level="DEBUG" />

Cherry picking

When troubleshooting, setting the log level to TRACE is a good starting point, as it captures detailed information about program execution. However, this will often generate an overwhelming amount of log data, likely more than necessary. By examining the logs, you can quickly identify non-essential data, allowing you to refine logging to focus only on critical information.

To reduce the amount of logging set to TRACE level in Log4j2, follow these steps:

1. Identify Specific Loggers: Determine which classes or packages require detailed TRACE logging and which can be logged at a higher level, like DEBUG or INFO. This ensures only necessary parts of the application log at TRACE level.

2. Set Logger Levels by Package or Class: In your log4j2.xml configuration file, specify different logging levels for each package or class. For example:

<AsyncLogger name="com.example.critical" level="TRACE" additivity="false"/>

<AsyncLogger name="com.example.general" level="INFO" additivity="false"/>

To identify specific classes or packages you want to keep at TRACE level using PatternLayout in Log4j2, you can configure your logging pattern to include indicators for each log message that will help in narrowing down critical areas for TRACE logging. Here’s how to approach it:

Set Up Initial TRACE Logging Configuration: Temporarily set the logging level to TRACE for broader packages or application-wide to capture detailed logs:

<AsyncLogger name="com.example" level="TRACE" additivity="false"/>
  1. Customize the Pattern to Include Class and Package Names: Use a detailed PatternLayout to include class names, method names, and even line numbers in the log output. This can help you identify which classes or areas generate excessive log output and which ones are critical. For example:

<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %c{1} - %M:%L - %msg%n" />

• %c{1}: Outputs the class name (use %c for full package and class).

• %M: Outputs the method name.

• %L: Outputs the line number.

With this layout, your logs will show timestamps, thread names, log levels, class names, method names, and line numbers, making it easier to trace and filter out specific classes or methods for TRACE.

3. Analyze the Log Output: Review the generated logs to observe which classes and methods are logging at TRACE frequently. Identify the ones crucial for debugging or requiring detailed insights. Classes with valuable diagnostic information should remain at TRACE, while others can be raised to DEBUG or INFO.

4. Refine Log Levels in Configuration: After identifying the classes or packages that benefit most from TRACE, configure them individually in log4j2.xml:

<AsyncLogger name="com.example.critical" level="TRACE" additivity="false"/>

<AsyncLogger name="com.example.general" level="INFO" additivity="false"/>

5. Adjust the Pattern Layout as Needed: Once you’ve narrowed down specific classes for TRACE level, you may simplify the PatternLayout if it was only used to aid in identification, improving readability in production logs.

This approach helps you use TRACE selectively, optimizing log verbosity and focusing on critical components while reducing noise in the logs.

Last updated