Implementing a Centralized Logging System for Liferay


Introduction
A centralized logging system could be used to collect logs from multiple sources and analyze them in a single location. This allows the user to obtain all of the necessary information to easily evaluate, monitor, and troubleshoot any problem in the server.
This document contains an approach to perform a centralized logging system for Liferay using an APM agent.
- Elastic search
- Kibana
- APM server
- APM Agent
Prerequisites
- Liferay DXP/Portal 7.X
- Basic knowledge of Liferay
- Basic Knowledge of Elastic and Kibana
Environmental Requirements
- Liferay Portal or DXP
- Elastic search
- Kibana
- APM Server
- APM agent
Centralized Logging System for Liferay using APM agent

Elastic Search
The elastic configuration file(elasticsearch.yml) should contain the following:
1xpack.security.enabled: true
2discovery.type: single-node
3xpack.security.authc.api_key.enabled: trueKibana
Kibana’s configuration file(kibana.yml) should contain the following:
1elasticsearch.username: "kibana_system"
2elastic search.password: "7Go5k7o4T5azKs5SLczd" #your kibana passwordAPM Agent
Install the APM agent in the server
APM Server
APM server configuration file should contain the following:
1apm-server:
2 host: "127.0.0.1:8200"
3output.elasticsearch:
4 hosts: ["localhost:9200"]
5 username: "elastic"
6 password: "elasticpassword"Liferay Configurations
To integrate Liferay with the APM agent, these steps need to be followed:
- Download the APM agent jar from the Elastic official site or the link http://kibana-host:5601/app/home#/tutorial/apm.
- In the setenv.sh file within CATALINA_OTPS add the location of jar file and also add the following properties.
1CATALINA_OPTS="$CATALINA_OPTS -javaagent:/etc/liferay-ce-portal-7.4.3.101-ga101/tomcat-9.0.80/bin/elastic-apm-agent-1.47.1.jar -Delastic.apm.service_name=liferay -Delastic.apm.application_packages=com.liferay,com -Delastic.apm.server_urls=http://127.0.0.1:8200 -Delastic.apm.log_level=ERROR -Delastic.apm.log_file=/etc/liferay-ce-portal-7.4.3.101-ga101/tomcat-9.0.80/logs/agent.log -Delastic.apm.log_sending=true"Start the Liferay server, log in to the Kibana, and check the APM page for updated metrics.
Now, from Kibana, all the logs related to the server can be monitored.
Conclusion
The centralized logging system is set up for Liferay using APM Agent.