Complete the code to write a log message to a file.
echo "Starting process..." >> [1]
The log message should be appended to the log file /var/log/process.log.
Complete the code to log an error message with a timestamp.
echo "$(date) ERROR: Disk space low" >> [1]
Error messages are commonly logged in /var/log/error.log to separate them from other logs.
Fix the error in the code to correctly log a warning message.
echo "WARNING: Low memory" [1] /var/log/warnings.log
Use >> to append the warning message to the log file without overwriting existing content.
Fill both blanks to create a function that logs messages with levels.
log_message() {
echo "$(date) [1]: $1" [2] /var/log/app.log
}The function logs messages with the level INFO and appends them to /var/log/app.log.
Fill all three blanks to create a log entry with dynamic level and message.
log() {
level=[1]
message=[2]
echo "$(date) $level: $message" [3] /var/log/custom.log
}The function assigns the first argument to level, the second to message, and appends the formatted log entry to /var/log/custom.log.