leafChat keeps logs automatically for a few weeks. You can view logs by date or by channel, and quickly search them for a particular word.
You can change how long the program keeps logs for, what it does with old logs (deletes or archives them) and set exceptions for specific channels if you want to keep logs forever from that channel, or not keep them at all.