Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: ✉️: Log4j appenders docs

There are two ways of configuring to configure log4j Logginglogging in WSO2 API Manager. You can manually edit the log4j.properties file, or configure logging through the management console. Configuration made through the management console can be persisted in the WSO2 registry so that it is available even after the server restarts. There is also an option to restore the original Log4j configuration from the log4j.properties file using the management console. However, if you modify the log4j.properties file and restart the server, the earlier log4j configuration persisted in the registry is overwritten.

Table of Contents
maxLevel4

For information on viewing the contents of the logs, see Application Logs and System Logs.

Configure

...

logging

Follow the instructions below to set up logging.

  1. Sign in to the APIM API-M Management Console.
  2. Click Configure > Logging
    The "Logging Configuration" window appears.
    Image Removed
  3. Select Persist All Configurations Changes if If you want your modifications to be persisted and available even after a server restart, select the Persist All Configurations Changes check box.
    Image Added
  4. Use the options in the following sections to configure the layout and the amount of information about system activity that you want to record.

...

Table of Contents
maxLevel4
minLevel4

Global Log4J

...

configuration 

This section allows you to assign a single log level and log pattern to all loggers.

  • Log Level - Reflects a minimum level that this logger cares about. You can view the hierarchy of levels belowlevels below.
  • Log Pattern - Defines the output format of the log file.

Configure Log4J

...

appenders 

Log4j allows logging requests to print to multiple destinations. These output destinations are called appenders. You can attach several appenders to one logger.

  • NameName -The  The name of an appender. By default, WSO2 ESB comes API Manager comes with the following log appenders configured:
    • CARBON_CONSOLE - Logs to the console when the server is running.
    • CARBON_LOGFILE - Writes the logs to <ESBto the <API-M_HOME>/repository/logs/wso2-esbwso2carbon.log file.
    • SERVICE_APPENDER - Writes mediation time audit messages to the <ESBAPI-M_HOME>/repository/logs/wso2-esbapigw-service.log file.
    • TRACE_APPENDER - Writes mediation time tracing/debug messages to the <ESBAPI-M_HOME>/repository/logs/wso2-esbapigw-trace.log for  file for tracing enabled services.
    • TRACE_MEMORYAPPENDER
    • CARBON_MEMORY
    • CARBON_SYS_LOG - Allows separation of the software that generates messages from the system that stores them and the software that reports and analyzes them.
  • Log pattern - Defines the output format of the log file.
  • Threshold - Filters log entries based on their level. For example, if the threshold is set to " WARN" will allow log entry , log entries are allowed to pass into the appender if its level is " WARN, " " ERROR " or " FATAL, " while other entries will be are discarded.
Hierarchy of

...

levels 
  • TRACE - Designates finerinformational events that are more fine-grained informational events than the DEBUG.
  • DEBUG - Designates fine-grained informational events that are most useful to debug an application.
  • INFO - Designates informational messages that highlight the progress of the application at coarse-grained level.
  • WARN - Designates potentially harmful situations.
  • ERROR - Designates error events that might still allow the application to continue running.
  • FATAL - Designates very severe error events that will presumably lead the application to abort.

Configure Log4J

...

loggers 

This section allows you to browse through all loggers, define a log level, and switch on/off additivity to any of them. You can filter loggers by using the first few characters (use the Starts With button) or by using a combination of characters (use the Contains button).

  • Logger - The name of a logger.
  • Parent Logger - The name of a parent logger.
  • Level - Allows to select the level (threshold) from the drop-down menu. After you specify the level for a certain logger, a log request for that logger will is enabled only be enabled if its level is equal or higher to that of the logger’s one. If a given logger is not assigned a level, then it inherits one from its closest ancestor with an assigned level. See hierarchy of levels above.
  • Additivity - Allows to inherit all the appenders of the parent Logger if set as "to True."
Example

Use the following procedure to enable logs to view HTTP headers and messages:

  1. In the Filter Loggers by field, enter wire and then click Contains
    You see org.apache.synapse.transport.http.wire will be displayed  displayed under Logger.
  2. Change the level of this logger to DEBUG.
  3. Search for the org.apache.synapse.transport.http.headers logger and change the level to DEBUG.

...

Alternatively, you can uncomment the entry for the two loggers as follows:

  1. Go to the <ESB<API-M_Home>HOME>/repository/conf directory and open the log4j.properties file with a text editor.
  2. Edit the entries for the two loggers as follows by removing the commented (#).
    log4j.logger.org.apache.synapse.transport.http.headers=DEBUG
    log4j.logger.org.apache.synapse.transport.http.wire=DEBUG 
  3. Save the changes.