Logging in shell script

We all enjoy the logging facilities in the modern programming language (e.g. log4j in java, c# logging in c#)

but what about shell script? The answer is an one liner


LOG(){echo "$(date +%c) $*"}

for console and

LOG(){echo "$(date +%c) $*" >> log.txt}

for txt out put.

Of course this is not the as sophisticated as the logging framework like log4j, but it simple and easy to use.

To use the function simply calls

LOG "Message"

Comments (0)

Post a Comment