XK0-005 · Question #10110
An administrator needs to look at a log for an application on a systemd-based system. There is no log for this application in /var/log. Which of the following is another way to view the application…
The correct answer is B. journalctl -u application. On systemd-based systems, application logs that are not written to /var/log can often be found in the systemd journal using the journalctl command.
Question
Options
- Atail -f /var/log/secure
- Bjournalctl -u application
- Csystemctl application.service
- Dwatch /var/lib/application/
How the community answered
(48 responses)- A8% (4)
- B88% (42)
- C2% (1)
- D2% (1)
Why each option
On systemd-based systems, application logs that are not written to `/var/log` can often be found in the systemd journal using the `journalctl` command.
tail -f /var/log/secure would display logs from the system's security log file, not necessarily the specific application's log if it's not writing there.
For systemd-based systems, applications managed by systemd often log to the systemd journal, which `journalctl` can query. The `-u application` option allows filtering logs specifically for a systemd unit named 'application', even if they are not explicitly written to a file in `/var/log`. This is a common method for viewing logs when traditional file-based logging is not used or is redirected to the journal.
systemctl application.service is used to manage (start, stop, status) systemd services, not to view their logs directly.
watch /var/lib/application/ would repeatedly execute a command, in this case `ls` on /var/lib/application/, which would show directory contents but not application logs.
Concept tested: Viewing systemd journal logs
Source: https://man7.org/linux/man-pages/man1/journalctl.1.html
Topics
Community Discussion
No community discussion yet for this question.