Technology Encyclopedia Home >How to view the Linux system log of the cloud server?

How to view the Linux system log of the cloud server?

To view the Linux system logs on a cloud server, you can use several standard commands and tools. Here's how:

  1. Check logs in /var/log/:
    Most Linux system logs are stored in the /var/log/ directory. Common logs include:

    • /var/log/syslog or /var/log/messages (general system logs)
    • /var/log/auth.log (authentication logs, e.g., SSH login attempts)
    • /var/log/kern.log (kernel-related logs)
    • /var/log/dmesg (boot and hardware-related logs)

    Example:

    cat /var/log/syslog
    

    Or use less for easier navigation:

    less /var/log/syslog
    
  2. Use journalctl (for systems with systemd):
    If your cloud server uses systemd, you can view logs with journalctl.

    Example:

    journalctl -xe  # View recent logs with detailed explanations
    

    To filter logs by a specific service (e.g., sshd):

    journalctl -u sshd
    
  3. Check boot logs with dmesg:
    To view kernel and hardware-related logs:

    dmesg | less
    
  4. Monitor logs in real-time with tail:
    Use tail -f to follow log updates in real-time.

    Example:

    tail -f /var/log/syslog
    

For cloud servers, Tencent Cloud provides enhanced log management services:

  • Tencent Cloud Log Service (CLS): Collects, stores, and analyzes logs from cloud servers, making it easier to search and monitor logs. You can integrate CLS with your Linux server to centralize log management.
  • Cloud Monitor: Helps track system performance and logs, providing alerts for critical events.

These tools simplify log analysis and troubleshooting for cloud-based Linux servers.