Challenge - 5 Problems
Logging Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this logging command?
Consider this bash script snippet that uses a simple logging function:
What will be the output format of the last command?
log() {
level=$1
message=$2
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $level: $message"
}
log "INFO" "Deployment started"What will be the output format of the last command?
Bash Scripting
log() {
level=$1
message=$2
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $level: $message"
}
log "INFO" "Deployment started"Attempts:
2 left
💡 Hint
Look at how the echo command formats the output string with date and level.
✗ Incorrect
The function prints the date and time in brackets, followed by the log level, a colon, and the message. The date format is YYYY-MM-DD HH:MM:SS.
❓ Configuration
intermediate1:30remaining
Which syslog configuration line sets the log level to 'warning' for a service?
In the syslog configuration file, you want to log only warnings and errors from the 'auth' facility. Which line correctly configures this?
Attempts:
2 left
💡 Hint
The log level 'warning' includes warnings and errors but excludes info and debug.
✗ Incorrect
The 'auth.warning' selector logs messages with level warning and higher (error, critical, etc.) from the auth facility.
❓ Troubleshoot
advanced2:00remaining
Why does this bash logging function fail to log multi-word messages correctly?
Given this function:
Why does the output only show 'Deployment' instead of the full message?
log() {
echo "[$(date)] $1: $2"
}
log INFO Deployment started successfullyWhy does the output only show 'Deployment' instead of the full message?
Bash Scripting
log() {
echo "[$(date)] $1: $2"
}
log INFO Deployment started successfullyAttempts:
2 left
💡 Hint
Think about how bash handles positional parameters and multiple words.
✗ Incorrect
In bash, $2 refers only to the second argument. The words after the second are separate arguments and not included in $2. To capture the full message, quotes or "$@" are needed.
🔀 Workflow
advanced2:30remaining
What is the correct order to set up a centralized logging system using rsyslog?
Arrange these steps in the correct order to configure a centralized logging server with rsyslog:
1. Configure clients to send logs to the server
2. Install rsyslog on server and clients
3. Configure server to receive remote logs
4. Restart rsyslog service on all machines
1. Configure clients to send logs to the server
2. Install rsyslog on server and clients
3. Configure server to receive remote logs
4. Restart rsyslog service on all machines
Attempts:
2 left
💡 Hint
You must install software before configuring it, and server config before client config.
✗ Incorrect
First install rsyslog everywhere, then configure the server to accept logs, then configure clients to send logs, finally restart services to apply changes.
✅ Best Practice
expert3:00remaining
Which logging practice helps avoid losing logs during high load in a bash script?
You have a bash script that logs messages to a file. Sometimes under heavy load, logs are lost or incomplete. Which practice best prevents this?
Attempts:
2 left
💡 Hint
Think about how to ensure logs are written safely and immediately to disk.
✗ Incorrect
Appending with '>>' ensures logs are added without overwriting. Flushing output immediately reduces risk of losing logs if script crashes or is interrupted.