Skip to content

350d/PimpMyLog

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

174 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pimp My Log

Pimp My Log is a web application for viewing and analyzing web server and application logs. It supports Apache, Nginx, PHP, MySQL, and other log types with a convenient web interface.

Features

  • πŸ“Š Real-time log viewing with automatic refresh
  • πŸ” Powerful search with regular expression support
  • 🎨 User-friendly web interface with filtering and sorting
  • πŸ” Authentication and user management system
  • πŸ“± Responsive design for mobile devices
  • πŸ“€ Export logs in various formats (CSV, JSON, XML, RSS, ATOM)
  • 🧩 Block-based parsing support for multi-line logs (MySQL Slow Log, etc.)
  • 🌍 Multi-language support
  • βš™οΈ Flexible configuration via JSON/PHP configuration files

Requirements

  • PHP >= 5.2.0 (PHP 8.0+ recommended)
  • Web server (Apache, Nginx, IIS)
  • PHP extensions: json, mbstring (optional)

Installation

Installation

git clone https://github.com/350d/PimpMyLog.git
cd PimpMyLog

Updating

To update to the latest version, pull the latest changes from the repository:

cd PimpMyLog
git pull origin master

If you have local modifications, you may need to stash them first:

git stash
git pull origin master
git stash pop

Configuration

  1. Copy the configuration file:

    cp cfg/config.example.php config.user.php
  2. Open the web interface:

    • Open http://your-domain.com/path-to-pimpmylog/ in your browser
    • Follow the setup wizard instructions
  3. Configure log access:

    • Specify paths to your log files in the configuration
    • Configure regular expressions for parsing (examples included)
    • Set up authentication if needed

Configuration Examples

Apache Error Log

{
  "files": {
    "apache_error": {
      "display": "Apache Error",
      "path": "/var/log/apache2/error.log",
      "refresh": 5,
      "max": 50,
      "format": {
        "regex": "|^\\[(.*)\\] \\[(.*)\\] (\\[client (.*)\\] )*((?!\\[client ).*)(, referer: (.*))*$|U",
        "match": {
          "Date": 1,
          "Severity": 2,
          "IP": 4,
          "Log": 5,
          "Referer": 7
        }
      }
    }
  }
}

PHP Error Log (ServerPilot)

{
  "files": {
    "php_error": {
      "display": "PHP Error Log",
      "path": "/srv/users/serverpilot/apps/YOURAPP/log/YOURAPP_php8.5.error.log",
      "refresh": 5,
      "max": 100,
      "format": {
        "regex": "|^\\[(.*)\\] PHP (.*): (.*) in (.*) on line (.*)$|",
        "match": {
          "Date": 1,
          "Severity": 2,
          "Message": 3,
          "File": 4,
          "Line": 5
        }
      }
    }
  }
}

MySQL Slow Log

Setup Instructions:

  1. Create log directory and set permissions:

    sudo mkdir -p /srv/users/serverpilot/apps/YOURAPP/log
    sudo chown mysql:mysql /srv/users/serverpilot/apps/YOURAPP/log
    sudo chmod 755 /srv/users/serverpilot/apps/YOURAPP/log
    sudo -u mysql touch /srv/users/serverpilot/apps/YOURAPP/log/mysql-slow.log
  2. Add path to AppArmor profile (if AppArmor is enabled):

    sudo nano /etc/apparmor.d/usr.sbin.mysqld
    # Add these lines in the log section:
    #   /srv/users/serverpilot/apps/YOURAPP/log/ r,
    #   /srv/users/serverpilot/apps/YOURAPP/log/** rw,
    sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
  3. Configure MySQL:

    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
    # Add or update:
    # slow_query_log = 1
    # slow_query_log_file = /srv/users/serverpilot/apps/YOURAPP/log/mysql-slow.log
    # long_query_time = 2
    sudo service mysql restart
  4. Enable slow query log:

    mysql -e "SET GLOBAL slow_query_log = 'ON';"
    mysql -e "SHOW VARIABLES LIKE 'slow_query%';"

Configuration Example:

{
  "files": {
    "mysqlslow": {
      "display": "MySQL Slow Log",
      "path": "/srv/users/serverpilot/apps/YOURAPP/log/mysql-slow.log",
      "refresh": 60,
      "max": 200,
      "format": {
        "block_start": "# Time:",
        "regex": "/# Time: ([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\\.[0-9]+Z.*?# Query_time: ([0-9.]+)\\s+Lock_time: ([0-9.]+).*?Rows_examined: ([0-9]+)\\n([\\s\\S]*?)(?=# Time:|\\z)/s",
        "match": {
          "Date": {
            "Y": 1,
            "m": 2,
            "d": 3,
            "H": 4,
            "i": 5,
            "s": 6
          },
          "Time": 7,
          "Lock": 8,
          "Rows": 9,
          "SQL": 10
        }
      }
    }
  }
}

ServerPilot β€” Log Locations

If your site is hosted on ServerPilot, logs are typically located in the following places:

Log Type Path
PHP Error Log /srv/users/serverpilot/apps/YOURAPP/log/YOURAPP_php8.5.error.log
PHP Access Log /srv/users/serverpilot/apps/YOURAPP/log/YOURAPP_php8.5.access.log
Apache Error Log /srv/users/serverpilot/apps/YOURAPP/log/YOURAPP_apache.error.log
Apache Access Log /srv/users/serverpilot/apps/YOURAPP/log/YOURAPP_apache.access.log
PHP-FPM Service Log /var/log/php8.5-fpm-sp.log

Note: Replace YOURAPP with your application name in ServerPilot. PHP version may vary (php7.4, php8.0, php8.1, php8.2, php8.3, php8.5, etc.).

ServerPilot Configuration Example

{
  "files": {
    "serverpilot_php_error": {
      "display": "PHP Error (ServerPilot)",
      "path": "/srv/users/serverpilot/apps/myapp/log/myapp_php8.5.error.log",
      "refresh": 5,
      "max": 100,
      "notify": true,
      "format": {
        "regex": "|^\\[(.*)\\] PHP (.*): (.*) in (.*) on line (.*)$|",
        "match": {
          "Date": 1,
          "Severity": 2,
          "Message": 3,
          "File": 4,
          "Line": 5
        },
        "types": {
          "Date": "date:H:i:s",
          "Severity": "badge:severity",
          "Message": "pre",
          "File": "txt",
          "Line": "numeral"
        }
      }
    },
    "serverpilot_php_access": {
      "display": "PHP Access (ServerPilot)",
      "path": "/srv/users/serverpilot/apps/myapp/log/myapp_php8.5.access.log",
      "refresh": 0,
      "max": 50,
      "format": {
        "regex": "|^(.*) - \\[(.*)\\] \"(.*) (.*) (.*)\" ([0-9]*) (.*) - (.*) (.*) (.*) \"(.*)\" \"(.*)\"|",
        "match": {
          "IP": 1,
          "Date": 2,
          "Method": 3,
          "URL": 4,
          "Protocol": 5,
          "Code": 6,
          "Size": 7,
          "Referer": 11,
          "UA": 12
        },
        "types": {
          "Date": "date:H:i:s",
          "IP": "ip:geo",
          "Code": "badge:http",
          "Size": "numeral:0b"
        }
      }
    }
  }
}

Project Structure

PimpMyLog/
β”œβ”€β”€ cfg/              # Configuration files and examples
β”œβ”€β”€ css/              # Stylesheets
β”œβ”€β”€ fonts/            # Fonts
β”œβ”€β”€ img/              # Images and icons
β”œβ”€β”€ inc/              # PHP libraries and classes
β”‚   β”œβ”€β”€ classes/      # Core classes (LogParser, Sentinel, Session)
β”‚   └── ...
β”œβ”€β”€ js/               # JavaScript files
β”œβ”€β”€ lang/             # Localization files
β”œβ”€β”€ tmp/              # Temporary files
β”œβ”€β”€ index.php         # Main entry point
β”œβ”€β”€ config.user.json  # Your configuration file (created during setup)
└── README.md         # This file

Security

  • Set proper file permissions for configuration files
  • Use authentication to protect log access
  • Restrict directory access via web server (.htaccess for Apache)
  • Do not place configuration files in public directories

License

GPL-3.0+

Support

Changes in This Version

  • βœ… Block-based parsing support for multi-line logs (MySQL Slow Log)
  • βœ… PHP 8.0+ compatibility
  • βœ… Improved configuration parsing error handling
  • βœ… ServerPilot configuration examples

About

🍭 Log viewer for your web server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • PHP 99.2%
  • Other 0.8%