sublime
atom
ubuntu
soap
+
+
clj
+
+
kali
+
+
+
+
micronaut
+
emacs
+
+
arch
+
xcode
+
+
packer
micronaut
+
+
+
htmx
intellij
+
+
express
dns
+
+
+
eslint
clickhouse
stencil
+
&&
laravel
+
+
+
+
nuxt
sails
sqlite
+
+
notepad++
r
+
bsd
+
webpack
+
+
rubymine
influxdb
โ‰ 
+
+
+
c++
+
+
gradle
+
+
+
+
+
+
puppet
+
rest
+
+
elm
+
+
+
+
grafana
+
scheme
Back to Blog
๐Ÿ“Š AlmaLinux Log Management: Complete System Monitoring Guide
AlmaLinux Log Management System Monitoring

๐Ÿ“Š AlmaLinux Log Management: Complete System Monitoring Guide

Published Sep 17, 2025

Master log management on AlmaLinux! Learn rsyslog, journald, logrotate, and monitoring tools. Complete beginner-friendly guide with real examples and troubleshooting tips.

28 min read
0 views
Table of Contents

๐Ÿ“Š AlmaLinux Log Management: Complete System Monitoring Guide

Welcome to the world of log management on AlmaLinux! ๐ŸŽ‰ Logs are like your systemโ€™s diary - they tell you everything thatโ€™s happening, helping you troubleshoot problems and monitor your serverโ€™s health. Whether youโ€™re a complete beginner or looking to improve your Linux skills, this guide will teach you everything about managing logs effectively! ๐Ÿš€

Log management might seem complex, but with the right approach, youโ€™ll become a log management expert in no time! ๐Ÿ’ช From understanding basic log files to setting up advanced monitoring systems, weโ€™ll cover it all step by step. Letโ€™s dive into this essential skill that every Linux administrator needs! โœจ

๐Ÿค” Why is Log Management Important?

Log management is crucial for maintaining a healthy AlmaLinux system! Hereโ€™s why you should master it:

  • ๐Ÿ” Problem Detection: Quickly identify and diagnose system issues
  • ๐Ÿ“ˆ Performance Monitoring: Track system performance and resource usage
  • ๐Ÿ›ก๏ธ Security Analysis: Monitor for unauthorized access and security threats
  • ๐Ÿ“Š Capacity Planning: Understand usage patterns for future planning
  • ๐Ÿ”ง Troubleshooting: Get detailed information when things go wrong
  • ๐Ÿ“‹ Compliance: Meet regulatory requirements for log retention
  • โšก Proactive Maintenance: Prevent problems before they become critical
  • ๐ŸŽฏ System Optimization: Identify bottlenecks and optimization opportunities

๐ŸŽฏ What You Need

Before we start managing logs, make sure you have:

โœ… AlmaLinux 8 or 9 installed and running โœ… Root or sudo access to modify system configuration โœ… Basic terminal knowledge (cd, ls, cat commands) โœ… Text editor familiarity (nano, vim, or gedit) โœ… Network connectivity for installing additional tools โœ… At least 2GB free disk space for log storage โœ… Understanding of basic Linux concepts (files, processes, services)

๐Ÿ“ Understanding AlmaLinux Log System

Letโ€™s start by understanding how AlmaLinux handles logs! ๐ŸŽ“

System Log Architecture

AlmaLinux uses multiple logging systems:

# View the main system log service
systemctl status rsyslog
# Output: Shows rsyslog service status

# Check systemd journal service
systemctl status systemd-journald
# Output: Shows journald service status

# View current log configuration
cat /etc/rsyslog.conf
# Output: Shows rsyslog configuration

Important Log Directories

# Main log directory
ls -la /var/log/
# Output: Shows all system log files

# System messages
tail -f /var/log/messages
# Output: Shows real-time system messages

# Authentication logs
tail -f /var/log/secure
# Output: Shows login attempts and security events

# Kernel messages
dmesg | tail -20
# Output: Shows recent kernel messages

๐Ÿ”ง Setting Up Basic Log Management

Configure rsyslog Service

# Check rsyslog status
sudo systemctl status rsyslog
# Output: Active (running) if working properly

# Enable rsyslog at boot
sudo systemctl enable rsyslog
# Output: Created symlink message

# Start rsyslog service
sudo systemctl start rsyslog
# Output: No output if successful

# View rsyslog configuration
sudo nano /etc/rsyslog.conf
# Add these useful settings:
# $ModLoad imudp
# $UDPServerRun 514
# $UDPServerAddress 127.0.0.1

Understanding Log Levels

# View different log severity levels
logger -p user.info "This is an info message"
logger -p user.warning "This is a warning message"
logger -p user.error "This is an error message"

# Check if messages appear in logs
tail -n 5 /var/log/messages
# Output: Shows your test messages with timestamps

๐ŸŒŸ Advanced rsyslog Configuration

Custom Log Rules

# Edit rsyslog configuration
sudo nano /etc/rsyslog.conf

# Add custom rules at the end:
# Mail system logs to separate file
mail.*                          /var/log/maillog

# Kernel messages to separate file
kern.*                          /var/log/kern.log

# Critical messages to console
*.crit                          /dev/console

# All logs except mail to messages
*.info;mail.none;authpriv.none  /var/log/messages

Remote Log Configuration

# Configure remote logging (sender)
sudo nano /etc/rsyslog.conf
# Add this line:
# *.* @@192.168.1.100:514

# Configure log server (receiver)
sudo nano /etc/rsyslog.conf
# Uncomment these lines:
# $ModLoad imudp
# $UDPServerRun 514

# Restart rsyslog after changes
sudo systemctl restart rsyslog
# Output: No output if successful

โœ… Working with systemd Journal

Basic Journal Commands

# View all journal entries
journalctl
# Output: Shows all log entries (use q to quit)

# View logs from today
journalctl --since today
# Output: Shows today's logs only

# View logs from specific service
journalctl -u sshd
# Output: Shows SSH service logs

# Follow logs in real-time
journalctl -f
# Output: Shows new log entries as they appear

# View logs from last boot
journalctl -b
# Output: Shows logs since last system boot

Advanced Journal Filtering

# View logs by priority
journalctl -p err
# Output: Shows only error-level messages

# View logs by time range
journalctl --since "2025-09-17 10:00:00" --until "2025-09-17 11:00:00"
# Output: Shows logs from specific time range

# View logs by user
journalctl _UID=1000
# Output: Shows logs from specific user ID

# View kernel messages only
journalctl -k
# Output: Shows kernel-related messages

# Show logs in JSON format
journalctl -o json-pretty -n 5
# Output: Shows last 5 entries in JSON format

๐Ÿ”ง Log Rotation with logrotate

Configure Log Rotation

# View logrotate configuration
cat /etc/logrotate.conf
# Output: Shows main logrotate settings

# Check individual service configurations
ls -la /etc/logrotate.d/
# Output: Shows per-service rotation configs

# Create custom rotation config
sudo nano /etc/logrotate.d/myapp
# Add this content:
/var/log/myapp.log {
    daily
    rotate 7
    compress
    missingok
    notifempty
    create 0644 root root
}

Test Log Rotation

# Test logrotate configuration
sudo logrotate -d /etc/logrotate.conf
# Output: Shows what would happen (dry run)

# Force log rotation
sudo logrotate -f /etc/logrotate.conf
# Output: Forces rotation immediately

# Check rotation status
cat /var/lib/logrotate/logrotate.status
# Output: Shows last rotation times

๐ŸŒŸ Setting Up Log Monitoring Tools

Install and Configure Logwatch

# Install logwatch
sudo dnf install logwatch -y
# Output: Package installation messages

# Run logwatch manually
sudo logwatch --detail Med --mailto root --service All
# Output: Generates and emails log summary

# Configure logwatch
sudo nano /etc/logwatch/conf/logwatch.conf
# Modify these settings:
# Detail = Med
# MailTo = [email protected]
# Range = yesterday

Install Rsyslog Analytics Tools

# Install additional monitoring tools
sudo dnf install multitail lnav -y
# Output: Installation confirmation

# Use multitail for multiple logs
multitail /var/log/messages /var/log/secure
# Output: Shows multiple log files simultaneously

# Use lnav for log analysis
lnav /var/log/messages
# Output: Enhanced log viewer with search and filtering

๐ŸŽฎ Quick Examples

Example 1: Monitor Web Server Logs

# Create web server log monitoring
sudo nano /etc/rsyslog.d/apache.conf
# Add this content:
$ModLoad imfile
$InputFileName /var/log/httpd/access_log
$InputFileTag apache-access:
$InputFileStateFile stat-apache-access
$InputFileSeverity info
$InputFileFacility local0
$InputRunFileMonitor

# Monitor in real-time
tail -f /var/log/httpd/access_log | grep -E "(404|500)"
# Output: Shows HTTP errors in real-time

Example 2: Security Log Analysis

# Monitor failed login attempts
grep "Failed password" /var/log/secure | tail -10
# Output: Shows recent failed login attempts

# Count failed logins by IP
grep "Failed password" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr
# Output: Shows IP addresses with most failed attempts

# Monitor successful logins
grep "Accepted password" /var/log/secure | tail -5
# Output: Shows recent successful logins

Example 3: Disk Space Monitoring

# Create disk space alert script
sudo nano /usr/local/bin/disk-alert.sh
# Add this content:
#!/bin/bash
THRESHOLD=80
for PARTITION in $(df -h | awk '{print $5}' | grep -E '[0-9]+%' | sed 's/%//'); do
    if [ $PARTITION -gt $THRESHOLD ]; then
        DEVICE=$(df -h | grep "$PARTITION%" | awk '{print $1}')
        logger -p user.warning "Disk space warning: $DEVICE is $PARTITION% full"
    fi
done

# Make script executable
sudo chmod +x /usr/local/bin/disk-alert.sh

# Test the script
sudo /usr/local/bin/disk-alert.sh
# Output: No output if disk usage is below threshold

๐Ÿšจ Fix Common Problems

Problem 1: Logs Filling Up Disk Space

Symptoms: System running out of disk space, slow performance

Solution:

# Check disk usage by logs
sudo du -sh /var/log/*
# Output: Shows space used by each log file

# Find large log files
find /var/log -type f -size +100M
# Output: Lists files larger than 100MB

# Emergency log cleanup
sudo journalctl --vacuum-time=7d
# Output: Keeps only last 7 days of journal logs

# Configure journal size limits
sudo nano /etc/systemd/journald.conf
# Add these lines:
SystemMaxUse=500M
SystemKeepFree=1G
SystemMaxFileSize=50M

Problem 2: Missing Log Entries

Symptoms: Expected log entries not appearing

Solution:

# Check if rsyslog is running
sudo systemctl status rsyslog
# Output: Should show active (running)

# Check rsyslog configuration syntax
sudo rsyslogd -N1
# Output: Shows configuration errors if any

# Test logging manually
logger "Test message from $(whoami)"
tail -n 5 /var/log/messages
# Output: Should show your test message

# Restart logging services
sudo systemctl restart rsyslog
sudo systemctl restart systemd-journald

Problem 3: Log Rotation Not Working

Symptoms: Log files growing without rotation

Solution:

# Check logrotate configuration
sudo logrotate -d /etc/logrotate.conf | grep -A 10 "error"
# Output: Shows configuration errors

# Check logrotate status
cat /var/lib/logrotate/logrotate.status
# Output: Shows last rotation times

# Force manual rotation
sudo logrotate -f /etc/logrotate.d/rsyslog
# Output: Forces rotation of rsyslog files

# Check cron job for logrotate
cat /etc/cron.daily/logrotate
# Output: Shows logrotate cron script

๐Ÿ“‹ Simple Commands Summary

CommandPurposeExample
journalctlView systemd logsjournalctl -f
tail -fFollow log filestail -f /var/log/messages
grepSearch log contentgrep "error" /var/log/messages
loggerCreate log entrieslogger "Test message"
logrotateRotate log fileslogrotate -f /etc/logrotate.conf
rsyslogdCheck rsyslog configrsyslogd -N1
systemctlManage log servicessystemctl restart rsyslog
dmesgView kernel messagesdmesg | tail -20

๐Ÿ’ก Tips for Success

Here are proven strategies to master log management! ๐ŸŒŸ

Best Practices

  • ๐Ÿ“Š Regular Monitoring: Check logs daily for unusual patterns
  • ๐Ÿ”„ Automate Rotation: Set up automatic log rotation to prevent disk issues
  • ๐ŸŽฏ Filter Wisely: Use specific searches instead of browsing entire logs
  • ๐Ÿ“ Document Patterns: Keep notes about common error patterns
  • โšก Performance Impact: Monitor logging overhead on busy systems
  • ๐Ÿ›ก๏ธ Security Focus: Pay special attention to authentication logs
  • ๐Ÿ“‹ Centralize Logs: Consider central logging for multiple servers
  • ๐Ÿ” Use Tools: Leverage log analysis tools for better insights

Optimization Tips

  • Set appropriate log levels to avoid information overload ๐Ÿ“ˆ
  • Use log aggregation tools for complex environments ๐Ÿ”ง
  • Implement log correlation for better troubleshooting ๐ŸŽฏ
  • Regular backup of critical logs for compliance โœ…
  • Monitor log generation rates to detect anomalies ๐Ÿ“Š
  • Use structured logging formats when possible ๐ŸŒŸ
  • Implement log-based alerting for critical events โšก
  • Regular cleanup of old, unnecessary log files ๐Ÿงน

๐Ÿ† What You Learned

Congratulations! Youโ€™ve mastered log management on AlmaLinux! ๐ŸŽ‰ Hereโ€™s what you can now do:

โœ… Understand Log Architecture: Know how rsyslog and journald work together โœ… Configure Log Services: Set up and customize logging services โœ… Manage Log Rotation: Prevent disk space issues with proper rotation โœ… Monitor System Health: Use logs to track system performance โœ… Troubleshoot Problems: Diagnose issues using log analysis โœ… Implement Security Monitoring: Track authentication and security events โœ… Use Advanced Tools: Leverage logwatch, multitail, and lnav โœ… Optimize Performance: Configure logging for best performance

๐ŸŽฏ Why This Matters

Effective log management is the foundation of reliable system administration! ๐Ÿš€ With these skills, you can:

  • Prevent Downtime: Catch problems before they become critical failures ๐Ÿ›ก๏ธ
  • Ensure Security: Monitor for threats and unauthorized access attempts ๐Ÿ”’
  • Maintain Performance: Identify and resolve performance bottlenecks โšก
  • Meet Compliance: Satisfy audit and regulatory requirements ๐Ÿ“‹
  • Enable Growth: Plan capacity and resources based on usage patterns ๐Ÿ“ˆ
  • Build Expertise: Develop advanced troubleshooting and monitoring skills ๐ŸŽ“

Log management transforms you from reactive firefighting to proactive system administration! Whether youโ€™re managing a single server or a complex infrastructure, these skills will serve you well throughout your Linux journey. Keep practicing, stay curious, and remember that every log entry tells a story about your system! โญ

Great work on completing this comprehensive log management guide! Youโ€™re well on your way to becoming a Linux administration expert! ๐Ÿ™Œ