This blog post is intended to offer some guidance around changing Liferay logging levels in a way that persists through a restart.
Normally in the Liferay portal application, you can set log levels for both built-in and custom loggers via the Server Administration section of the control panel. While this provides an excellent method to control log levels, the custom log settings for Liferay log levels do not persist when the Liferay instance is restarted.
To adjust log levels permanently, we have to use a portal-log4j-ext.xml file. Note that this method works only for classes from the core portal implementation portal-impl. To override the default log level of a class in a specific OSGi module, please see https://help.liferay.com/hc/en-us/articles/360018168751-Adjusting-Module-Logging.
To create this file in the Liferay application, follow these steps:
1. Make a copy of the
portal-impl.jar from the Liferay webapp,
webapps/ROOT/WEB-INF/lib/ directory to a temporary location of your choice.
2. In the temporary location, extract the portal-impl.jar file.
3. In the extracted
portal-impl.jar, navigate to the
4. Rename the
portal-log4j.xml file to
5. Open the portal-log4j-ext.xml file.
6. Modify the priority level as desired.
For example: if you’d like to set the log level to DEBUG for com.liferay.asset.publisher.web, change the category’s log level as shown below:
<category name="com.liferay.asset.publisher.web"> <priority value="DEBUG" /> </category>
7. Save changes made to the
8. Copy the updated
portal-log4j-ext.xml file to
9. Startup Liferay
10. Navigate to the Server Administration section of the control panel and verify that the log level changes made to the file are showing up in the control panel.
This blog post offers a simple solution to set up the log levels to persist through a restart in Liferay. And this falls back to our vast experience with the maintenance of the application.
If you have questions on how you can best leverage our DevOps expertise and/or need help with your DevOps implementation, please engage with us via comments on this blog post, or reach out to us.
You can also continue to explore our DevOps expertise at the following page. You can also engage with us on development best practices, and other articles in the general application development space here.