Versions Compared

Key

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

...

Java logging and Log4j Integration

Include PageShared:Java Logging and Log4j IntegrationShared:Java Logging and Log4j IntegrationCarbon 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.

...