Introduction to Logging
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. There are several ways in which the system and application logs of a running Carbon instance can be viewed.
- Through the Management Console.
- Through the log files that are stored in <PRODUCT_HOME>/repository/logs folder. The folder contains current logs in a log file with a date stamp. Older logs are archived in "wso2carbon.log" file.
- Through the command prompt/shell terminal that opens when running the "wso2server.bat"/"wso2server.sh" files to start the Carbon server.
WSO2 products use a log4j-based logging mechanism through Apache Commons Logging facade library. The log4j.properties file which governs how logging is performed by the server can be found in <PRODUCT_HOME>/repository/conf directory.
There are two ways to configuring log4j.
- Manually editing the log4j.properties.
- Â Logging configuration through the management console. Changes apply at run time.
The latter is recommended because all changes made to Log4j through the management console are persisted in the WSO2 Registry. Therefore, those changes will be available after server restarts. Any changes to the logging configuration you make through the management console will get priority over what is defined in the actual log4j.properties file. However, if you modify the log4j.properties file and restart the server, the earlier log4j configuration which persisted in the registry will be overwritten. There is also an option in the management console to restore the original Log4j configuration from the log4j.properties file. Â
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 section Feature Management.Â