RE: How to Log Server Start/Stop time in Database

Jamie Sammons, modified 3 Years ago. New Member Posts: 11 Join Date: 2/12/20 Recent Posts

Use Case:
We want  to Log Server Start/Stop time in database.

Example: for Normal Web-App we use "ServletContextListener" which get triggered at server start/stop and log time in DB.
 

Explanation: 
I like to log server start/stop time,
do Liferay has "ServletContextListener" like feature
OR is there any Inbulit Method from where I can fetch the server start and stop time 

thumbnail
Mohammed Yasin, modified 3 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi ,
You can get the time when the  Liferay was started from PortalUtil.getUptime(). In case you need an event to capture this, then you can look into the Global Start up event that runs once when the portal initializes.

https://help.liferay.com/hc/en-us/articles/360035828151-Liferay-DXP-Startup-Phases#portal-startup-events

Jamie Sammons, modified 3 Years ago. New Member Posts: 11 Join Date: 2/12/20 Recent Posts

Thanks,
for the response, just curious to know do we have any stop time as well, 

thumbnail
Mohammed Yasin, modified 3 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi ,

You can capture that from Global Shut Down event , You can refer below property

https://docs.liferay.com/dxp/portal/7.4-latest/propertiesdoc/portal.properties.html#Shutdown%20Events