Skip to main content

Analyzing Log Files: Linux & Windows

Ieva Z. avatar
Written by Ieva Z.
Updated over a week ago

๐Ÿ”Why Logs Matter

Logs are essential for troubleshooting, monitoring performance, hardening security, and auditing compliance. Whether you're managing a single VM or a fleet of servers, knowing where and how to analyze logs quickly can save you hoursโ€”or worse, downtime.

๐Ÿง Linux Distributions & Log Locations

All Linux distros log to /var/log/ by default, but file structure varies slightly:

Common files of note:

  • Kernel & boot messages: dmesg, /var/log/dmesg, /var/log/kern.log (Debian).

  • Application logs: e.g., /var/log/nginx/access.log, /var/log/httpd/error.log.

  • Mail logs (/var/log/maillog), firewall logs, audit/audit.log, btmp, wtmp, utmp.

โš™๏ธ Using systemd and journalctl

All distros above use systemd, and logs can be accessed via journalctl:

  • View all logs:

    journalctl

  • Filter by unit (e.g. nginx):

    journalctl -u nginx.service

  • Time-range filtering:

    journalctl --since "2025-06-29 00:00" --until "2025-06-30 23:59"

  • Follow live updates:

    journalctl -u sshd -f

    Useful flags:

    • -p err to show errors only

    • -k for kernel logs

    • -b for current boot session

๐ŸชŸ Windows Server 2019 & 2022: Event Viewer

Analysing logs via Event Viewer (WN 2019/2022):

  • Windows Logs:

    • Application: application-level events

    • Security: login attempts, policy changes

    • System: OS-level issues and driver errors

  • Applications and Services Logs:

    • Specific services (e.g., IIS, DNS)

    • Microsoft โ†’ Windows logs, e.g., HardwareEvents or Windows Update

    • Forwarded Events if collecting logs from other machines

  • Custom Views:
    Set up filters for RDP, failures, or hardware alerts to streamline incident identification.

  • ETW & PowerShell:
    Efficient event export:

    Get-WinEvent -FilterHashtable @{LogName='System'; StartTime=(Get-Date).AddDays(-1)} | Export-Csv system-events.csv

๐Ÿ›ก๏ธ Adding Proactive Monitoring & Security

Consider installing:

  • Fail2Ban on Linux (supports AlmaLinux, Ubuntu, Debian):

sudo apt install fail2ban  # Ubuntu/Debian
sudo dnf install fail2ban # Alma/Rocky

Blocks malicious IPs based on auth log patterns.

  • Lynis for compliance checks:

sudo apt install lynis # Debian/Ubuntu

Performs system audits.

Did this answer your question?