How can I log to a specific file in linux using logger command?

bash, logging

Solution

I don't think you really need to (or want to) involve `logger`/`syslog` for this. Simply replace the last line of the script with:

echo "Exit code of my program is $exitvalue" >> /some/file/that/you/can/write/to

Problem

I will run the following script: ``` #!/bin/bash ./myprogram #get exit code exitvalue=$? #log exit code value to /var/log/messages logger -s "exit code of my program is " $exitvalue ``` But I don't want log message to be written in `/var/log/messages` because I don't have root privileges. Instead I want it to be written to a file in my home directory: `/home/myuser/mylog` How should I modify `logger` command above?

Original source