journalctl command --view systemd management logs

You can use the journalctl command to see the logs of applications (server applications) managed by systemd. Execute with root privileges with sudo.

sudo journalctl

The log contains the date, time, host name, application name, process ID, and message.

Jun 02 12:17:26 myhost systemd [75667]: Received SIGRTMIN + 24 from PID 81968 (kill).
Jun 02 14:11:19 myhost systemd [88231]: Reached target Paths.
Jun 02 14:11:19 myhost systemd [88231]: Reached target Timers.
Jun 02 14:11:19 myhost systemd [88231]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jun 02 14:11:19 myhost systemd [88231]: Listening on GnuPG cryptographic agent and passphrase cache.
Jun 02 14:11:19 myhost systemd [88231]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jun 02 14:11:19 myhost systemd [88231]: Listening on REST API socket for snapd user session agent.
Jun 02 14:11:19 myhost systemd [88231]: Listening on GnuPG network certificate management daemon.
Jun 02 14:11:19 myhost systemd [88231]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jun 02 14:11:19 myhost systemd [88231]: Reached target Sockets.
Jun 02 14:11:19 myhost systemd [88231]: Reached target Basic System.
Jun 02 14:11:19 myhost systemd [88231]: Reached target Default.
Jun 02 14:11:19 myhost systemd [88231]: Startup finished in 20ms.

The log file will be opened using vi, so press "Shift + G". You can move to the bottom.

Extract only the log of a specific application

To retrieve only the logs for a specific application, specify the unit name with "-u". You can see it from the latest log by specifying the "-r" option.

View Apache logs

Display the log of Apache.

#Apache
sudo journalctl -r -u apache2

View MariaDB logs

View MariaDB logs.

#MariaDB
sudo journalctl -r -u mariadb

View SSH server logs

View SSH server logs.

# SSH server
sudo journalctl -r -u sshd

View Postfix logs

#Postfix
sudo journalctl -r -u postfix

View cron logs

# cron
sudo journalctl -r -u cron

View FTP server logs

#FTP server
sudo journalctl -r -u vsftpd

View Redis server logs

#Redis server
sudo journalctl -r -u redis-server

journalctl options

It is an option of journalctl.

journalctl [options ...] [match ...]

Query the journal.

option:
     --system Show system journal
     --user Shows the user journal of the current user
  -M --machine = CONTAINER Works with local container
  -S --since = DATE Show entries older than the specified date
  -U --until = DATE Show entries newer than the specified date
  -c --cursor = CURSOR Show entries starting with the specified cursor
     --after-cursor = CURSOR Show entry after the specified cursor
     --show-cursor Print cursor after every entry
  -b --boot [= ID] Shows the current boot or the specified boot
     --list-boots Shows brief information about recorded boots
  -k --dmesg Show kernel message log from current boot
  -u --unit = UNIT Display logs from the specified unit
     --user-unit = UNIT Displays the log of the specified user unit.
  -t --identifier = STRING Show entries with the specified syslog identifier
  -p --priority = RANGE Shows entries with the specified priority
  -g --grep = PATTERN Shows entries where MESSSAGE matches PATTERN
     --case-sensitive [= BOOL] Case-sensitive or unknowingly match
  -e --pager-end Jump immediately to the end of the pager
  -f --follow Follow the journal
  -n --lines [= INTEGER] Number of journal entries to display
     --no-tail Show all rows even in follow mode
  -r --reverse Show the latest entry first
  -o --output = STRING Change journal output mode (short, short-precise,
                               short-iso, short-iso-precise, short-full,
                               Short monotonous, short UNIX, verbose, export,
                               json, json-pretty, json-sse, cat)
     --output-fields = LIST Details / Export / Select fields to print in json mode
     --utc Coordinated Universal Time (UTC) Express Time
  -x --catalog Add message description if possible
     --no-full Ellipsize field
  -a --all Show all fields, including those that are too long to print
  -q --quiet Do not display informational messages and privilege warnings
     --no-pager Do not pipe output to pager
     --no-hostname Suppress the output of the hostname field
  -m --merge Show entries for all available journals
  -D --directory = Show journal files in PATH directory
     --file = View PATH journal file
     --root = ROOT Operate files under the root directory
     --interval = TIME Interval for changing the FSS sealing key
     --verify-key = KEY Specifies the FSS verification key
     Overriding FSS key pairs using --force --setup-keys

command:
  -h --help Display this help text
     --version Show package version
  -N --fields Lists all currently used field names
  -F --field = FIELD Lists all values ​​taken by the specified field
     --disk-usage Shows total disk usage for all journal files
     --vacuum-size = BYTES Reduces disk usage to less than the specified size
     --vacuum-files = INT Leave only the specified number of journal files
     --vacuum-time = TIME Deletes journal files older than the specified time
      --verify Check the integrity of the journal file
      --sync Synchronize unwritten journal messages to disk
      --flush flush all journal data from / run to / var
      --rotate Requests immediate rotation of the journal file.
      --header Show header information for the journal
      --list-catalog Shows all message IDs in the catalog
      --dump-catalog Shows message catalog entries
      --update-catalog Updates the message catalog database
      --new-id128 Generate a new 128-bit ID
      --setup-keys Generate a new FSS key pair

Associated Information