In Linux, I know how to write a simply message to the /var/log/messages
file, in a simple shell script I created:
#!/bin/bash
logger \"have fun!\"
<
@chepner make a good point that logger
is dedicated to logging messages.
I do need to mention that @Thomas Haratyk simply inquired why I didn't simply use echo
.
At the time, I didn't know about echo, as I'm learning shell-scripting
, but he was right.
My simple solution is now this:
#!/bin/bash
echo "This logs to where I want, but using echo" > /var/log/mycustomlog
The example above will overwrite the file after the >
So, I can append to that file with this:
#!/bin/bash
echo "I will just append to my custom log file" >> /var/log/customlog
Thanks guys!
/var/log/
, but I'm sure there are other good ideas out there. And since I didn't create a daemon, /var/log/
probably isn't the best place for my custom log file. (just saying)