You would probably want to use syslog for this, and then go a step further to separate out the cli (and webui) commands from the rest of the logs, put them in their own log file and rotate them as desired (likely with a different retention range as regular syslog)
From a *nix point of view, this is easily done using either rsyslog or syslog-ng to split the loga based on regular expressions and then logrotate.d to handle the rotations.
Hth