The log_input and log_output parameters enable sudo to run a command in pseudo-tty and log all user input and all output sent to the screen receptively.
A custom directory can be specified through the iolog_dir parameter.
Defaults log_input, log_output
NOTE: There are some escape sequences supported such as %{seq} which expands to a monotonically increasing base-36 sequence number, such as 000001, where every two digits are used to form a new directory, e.g. 00/00/01 as in the example below:
cd /var/log/sudo-io/ ls cd 00/00/01 ls cat log