Configuring Logging
To configure logging via WSO2 Business Activity Monitor (BAM):
Ensure that you have installed WSO2 Business Activity Monitor 2.4.0 (or above) version, prior to start configuring logging in WSO2 Private PaaS.
Step 1 - Enable log publishing to BAM
To enable log publishing from WSO2 products to BAM
The following steps need to be carried out on all WSO2 products where cartridges are available on WSO2 Private PaaS.
Navigate to the
lo4j.properties
file, which is in the<PRODUCT_HOME>/repository/conf/
directory, and addLOGEVENT
to the root logger.Update the properties in the
LOGEVENT
appender appropriately.For example:
log4j.appender.LOGEVENT=org.wso2.carbon.logging.appender.LogEventAppender log4j.appender.LOGEVENT.url=tcp://localhost:7612 log4j.appender.LOGEVENT.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout log4j.appender.LOGEVENT.columnList=%T,%S,%A,%d,%c,%p,%m,%H,%I,%Stacktrace log4j.appender.LOGEVENT.userName=admin log4j.appender.LOGEVENT.password=admin log4j.appender.LOGEVENT.processingLimit=1000 log4j.appender.LOGEVENT.maxTolerableConsecutiveFailure=20
Step 2 - Set up the Log Summarizer
Log Summarizer is a feature for BAM, which reads the logs from Cassandra and summarizes them at the end of each day at 1.00AM (default). Log Summarizer reads all the logs from the previous day and writes them to a file in a Hadoop Distributed File System (HDFS) and deletes the column family in Cassandra to save space.
To setup the Log Summarizer
Copy the following JAR to the
<BAM_HOME>/repository/components/dropins/
directory.<STRATOS_INSTALLER>/config/bam/repository/componants/dropins/org.wso2.carbon.logging.summarizer-4.2.0.jar
- Copy the
summarizer-config.xml
file, which is in the<STRATOS_INSTALLER>/config/bam/repository/conf/etc/
directory, to the<BAM_HOME>/repository/conf/etc/
directory. - Update the following configurations in the
summarizer-config.xml
file, which is in the the<BAM_HOME>/repository/conf/etc/
directory.Update the following configurations:
<isDataFromCassandra>true</isDataFromCassandra> <deleteColFamily>true</deleteColFamily>
Enter the Cassandra database (DB) details as follows:
<cassandraHost>localhost:9161</cassandraHost> <userName>admin</userName> <password>admin</password>
Where
cassandraHost
is the location where the logs were published, anduserName
andpassword
are the credentials used to access the Cassandra DB.Direct the following configuration to the HDFS file system where the logs need to be archived.
For example:<hdfsConfig>hdfs://localhost:9000</hdfsConfig> <archivedLogLocation>/stratos/archivedLogs/</archivedLogLocation>
Enable the
hive.insert.into.multilevel.dirs
property as follows in thehive-site.xml
file, which is in the<BAM_HOME>/repository/conf/advanced/
directory and point it to a local pseudo distributed mode Hadoop installation.
hive.insert.into.multilevel.dirs=true
Setting up Hadoop in a local pseudo distributed mode
A HDFS file system is needed for the logs to be archived. Only Hadoop versions 1.x are compatible with Log Summarizer. Therefore, Hadoop needs to be set up for the Log Summarizer to work. For information on setting up Hadoop in a local pseudo distributed mode, go to Pseudo-Distributed Operation.
After Hadoop is setup, every night the logs will be written to a file. Individual logs will be written for each tenant per service. For example, If the archived log location in the summarizer-config.xml
file is set to the /stratos/archivedLogs/
directory, the logs for the Stratos service, for the super tenant, for May 12, 2014 will be written to the following file:
<hdfs root>/stratos/archivedLogs/0/stratos/2014.05.12.log
Step 3 - Configure Log Viewer API
Log Viewer is an admin service that is available in Apache Stratos, which is used to view the published logs. Log Viewer can be enabled and pointed to a remote Cassandra cluster in order to retrieve logs.
To configure the Log Viewer
The following steps need to be carried out on all WSO2 products where cartridges are available on WSO2 Private PaaS.
Copy the
<PRODUCT_HOME>/config/all/repository/conf/etc/logging-config.xml
file to the<BAM_HOME>/repository/conf/etc/
directory.Edit the following configurations in the
l
ogging-config.xml
file, which is in the<BAM_HOME>/repository/conf/etc/
directory.
<isDataFromCassandra>true</isDataFromCassandra> <cassandraHost>localhost:9170</cassandraHost> <userName>admin</userName> <password>admin</password> <archivedHost>hdfs://localhost:9000</archivedHost> <archivedHDFSPath>/stratos/archivedLogs/</archivedHDFSPath> <archivedUser>admin</archivedUser> <archivedPassword>admin</archivedPassword>
- Add the dashboard to BAM by copying the
Private_PaaS_Statistics_Monitoring.tbox
toolbox, which is available in the<STRATOS_INSTALLER>/config/bam/
directory, to the<BAM_HOME>/repository/deployment/server/bam-toolbox/
directory.