Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Logging is one of the most important aspects of a production-grade server. A properly configured logging system is vital in identifying errors, security threats and usage patterns. All WSO2 products are shipped with the log4j logging capabilities, which generates all the administrative activities and server side logs.  The log4j.properties file, which governs how logging is performed by the server, can be found in the <PRODUCT_HOME>/repository/conf directory.

Logging functionality is provided by the following feature in the WSO2 feature repository:

Name : WSO2 Carbon - Logging Management Feature 
Identifier : org.wso2.carbon.logging.mgt.feature.group

If the above feature is not bundled in your product by default, you can install it using the instructions given in the Feature Management section. Go to the documentation of your Carbon product for more details on how to use the logging feature. 

Java logging and Log4j Integration

Carbon 4.2.0 version onwards, in addition to the logs from libraries that use Log4j, all logs from the libraries (such as, Tomcat, Hazelcast and more) that use Java logging framework are also visible in log files.  Prior to this integration between Java logging and Log4j, when Java logging is enabled in Carbon, both Log4j and Java logging would try to write to the same .log files at the same time using two I/O streams. The latter will lead to log files getting corrupted. Furthermore, on Windows operating systems as file writing is a slower operation, the chance of log file corruption may be higher.

Therefore, as a result of this integration in Carbon 4.2.0, only the Log4j appenders will write to the log files. If the Java Logging Handlers have logs, these logs will be delegated to the log events of the corresponding Log4j appenders. A Pub/Sub registry pattern implementation has been used in the latter mentioned scenario to plug the handlers and appenders. 

Default Log4j  in the log4j.properties file appenders, such as ConsoleAppender and DailyRollingAppender have been extended to carryout this implementation as shown below.

Old PropertyNew Property
org.apache.log4j.ConsoleAppenderorg.wso2.carbon.logging.appenders.CarbonConsoleAppender
org.apache.log4j.DailyRollingFileAppenderorg.wso2.carbon.logging.appenders.CarbonDailyRollingFileAppender

Remedies for log growth

Log growth can be managed by the following configurations in the <PRODUCT_HOME>/repository/conf/log4j.properties file.

  • Configurable log rotation: By default, log rotation is on a daily basis.
  • Log rotation based on time as opposed to size: This helps to inspect the events that occurred during a specific time.
  • Log files are archived to maximise the use of space.

The log4j-based logging mechanism uses appenders to append all the log messages into a file. That is, at the end of the log rotation period, a new file will be created with the appended logs and archived. The name of the archived log file will always contain the date on which the file is archived. 

  • No labels