Logging commands is a part of many packages, including ACL extensions. Your question is too general because you did not specify the OS.
Also, try the logfile options available in the sudoers configuration file and see if there is anything there to help you.
If you restrict the sudo configuration to a bare minimum number of commands per user, you should be ok with standard sudoers logging.
man sudoers
In other words, you should not give sudoers permission to use vi.
This is discussed in the sudo man page:
So... don't give users permissions to programs that allow shell escapes...... Heck, on our systems, no one is allowed to sudo... and if they were, they would be given very limited command privs.... (certainly not vi !)