Do logging and send proper status codes.