Retrieve chat history

You can enable Audit logs and it will logs chats into /openfire/logs/ (Server > Server Settings > Message Audit Policy). But these logs are in xml format, not read friendly. You can try using this app to view them Openfire Audit Log Reader