This is the latest release in the 6.x.x family. For EI 7.0.0, click here.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are three main components when configuring log4j: LoggersAppenders, and Layouts.

Table of Contents

Setting the log level

The log level can be set specifically for each appender in the log4j2.properties file by setting the threshold value. If a log level is not specifically given for an appender as explained below, the root log level (INFO) will apply to all appenders by default.

...

LevelDescription
OFFThe highest possible log level. This is intended for disabling logging.
FATALIndicates server errors that cause premature termination. These logs are expected to be immediately visible on the command line that you used for starting the server.
ERRORIndicates other runtime errors or unexpected conditions. These logs are expected to be immediately visible on the command line that you used for starting the server.
WARNIndicates the use of deprecated APIs, poor use of API, possible errors, and other runtime situations that are undesirable or unexpected but not necessarily wrong. These logs are expected to be immediately visible on the command line that you used for starting the server.
INFOIndicates important runtime events, such as server startup/shutdown. These logs are expected to be immediately visible on the command line that you used for starting the server . It is recommended to keep these logs to a minimum.
DEBUGProvides detailed information on the flow through the system. This information is expected to be written to logs only. Generally, most lines logged by your application should be written as DEBUG logs.
TRACEProvides additional details on the behavior of events and services. This information is expected to be written to logs only.


Setting the log pattern

The log pattern defines the output format of the log file. This is the layout pattern that describes the log message format.

Identifying forged messages: The conversion character 'u' can be used in the pattern layout to log a UUID. For example, the log pattern can be  [%u] [%d] %5p {%c} - %m%ex%n, where [%u] is the UUID.

Setting the Sys Log Host

The IP address of the system log server. The syslog server is a dedicated log server for many applications. It runs in a particular TCP port in a separate machine, which can be identified by an IP address.

Setting the Facility

The log message type sent to the system log server.

Setting the Threshold

Filters log entries based on their level. For example, threshold set to 'WARN' will allow the log entry to pass into appender. If its level is 'WARN', 'ERROR' or 'FATAL', other entries will be discarded. This is the minimum log level at which you can log a message. See descriptions of the available log levels.

Configuring Log4j Appenders

This section allows you to configure appenders individually. Log4j allows logging requests to print to multiple destinations. These output destinations are called 'Appenders'. You can attach several appenders to one logger.

  • CARBON_CONSOLE: Logs to the console when the server is running.
  • CARBON_LOGFILE: Writes the logs to MI_HOME/repository/logs/wso2carbon.log .
  • SERVICE_APPENDER: Writes service invocations to MI_HOME/repository/logswso2-MI-service.log.
  • ERROR_LOGFILE: Writes warning/error messages to the MI_HOME/repository/logs/wso2-MI-service.log.
  • TRACE _ APPENDER: Writes tracing/debug messages to the MI_HOME/repository/logs/wso2-MI-trace.log for tracing enabled services.
  • CARBON _ MEMORY:
  • CARBON_SYS_LOG: Allows separating the software that generates messages, from the system that stores them and the software that reports and analyzes them.
  • CARBON_TRACE_LOGFILE:

Configuring Log4j Loggers

A Logger is an object used to log messages for a specific system or application component.

...