Write to custom log file from a Bash script

前端 未结 5 608
渐次进展
渐次进展 2021-02-03 18:47

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!\"
<         


        
5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 18:55

    There's good amount of detail on logging for shell scripts via global varaibles of shell. We can emulate the similar kind of logging in shell script: http://www.cubicrace.com/2016/03/efficient-logging-mechnism-in-shell.html The post has details on introdducing log levels like INFO , DEBUG, ERROR. Tracing details like script entry, script exit, function entry, function exit.

    Sample Log:

提交回复
热议问题