On my Arch system, failed attempts to run sudo cause a line like this to be added to the logs (note the USER=root):
Nov 20 14:59:31 oregano sudo[191472]: bob : user NOT in sudoers ; TTY=pts/26 ; PWD=/home/bob ; USER=root ; COMMAND=/sbin/ls
In this case, as the user bob who isn't in sudoers, I had run:
$ sudo ls
bob is not in the sudoers file.
I was wondering what the USER=root means. Is it always the user that I tried to switch to? When I ran sudo -iu bob to (successfully) become the bob user, I got (here, USER=bob):
Nov 20 14:59:28 oregano sudo[191408]: terdon : TTY=pts/25 ; PWD=/home/bob ; USER=bob ; COMMAND=/bin/bash
So it looks like it is indeed reporting sudo's target user. Is it as simple as that though? Where is this documented? How can I see exactly what USER= is supposed to show? My test suggests it's as I describe, but I would like to confirm it somehow.