I would like to log out all my "set -x" output into my syslog file. However, the syslog file has my own custom format.
But set -x output does not have formatting.
How can I do that?
I would like to log out all my "set -x" output into my syslog file. However, the syslog file has my own custom format.
But set -x output does not have formatting.
How can I do that?
If you look at print_cmd.c
in the Bash source code, you'll see that the format of set -x
output is not configurable.
You could trap the DEBUG
"signal" to implement your own custom logging, e.g.
trap 'logger -p user.debug -t SHELLSCRIPT -- "$BASH_COMMAND" || :' DEBUG
to send all commands to syslog with facility user
, level debug
, and tag SHELLSCRIPT
.