How to manage your Magento logs with Graylog2

Stefan Wieczorek —  August 6, 2012 — 5 Comments

How to manage your Magento logs with Graylog2

In this post i will explain what Graylog2 is and how to use it with magento.

By default magento stores exceptions and other information in log files which is fine for development but in production you never see what happens in the dark. If you run a magento store in multi server environment you also have the problem that each webserver has it’s own log files. I thought it would be very nice to have GUI where i can see all log messages of all webservers in one central place.

What is Graylog2?

Graylog2 is an open source log management solution that stores your logs in a ElasticSearch database.
It consists of a server written in Java that accepts your syslog messages via TCP, UDP or AMQP and stores it in the database.
It also come with a nice web interface that allows you to manage the log messages from your web browser.

Graylog2 Screenshot 1

Graylog2 Screenshot 2

Graylog2 Screenshot 3

Graylog2 Screenshot 4

Graylog2 Screenshot 5

Graylog2 Screenshot 6

Integration in Magento

Before we can start using Graylog2 with our magento store we need a running Graylog2 instance.
You can install the Graylog2 Server + Graylog2 Web Interface by yourself or you can use our AMI for the Amazon EC2 Cloud.
A detailed instruction how to install and configure Graylog2 by yourself can be found on the Graylog2 website.

Step 1: Creating a Amazon EC2 Instance for Graylog2

Login into Amazon EC2 Management Console and launch instance. Afterwards click on “Community AMIs” and search for: ami-2767cc4e
Launch Amazon EC2 Instance

Select your instance type: micro, small or medium and create the instance
Launch Amazon EC2 Instance

Go to Network & Security and Allocate New IP Address to your EC2 instance
Launch Amazon EC2 Instance

Login into your EC2 instance via SSH (make sure SSH and UDP is allowed in your security group)

  ssh mgt@
  password: mgt (change your password with "passwd")

Edit Vhost and set your ServerName

  sudo nano /etc/apache2/sites-enabled/graylog2
  <VirtualHost *:80>
    DocumentRoot /var/www/graylog2-web-interface-0.9.6p1/public
    <Directory /var/www/graylog2-web-interface-0.9.6p1/public>
        Allow from all
        Options -MultiViews
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined

Restart apache2

  sudo /etc/init.d/apache2 restart

Go to your home directory /home/mgt and start Graylog


Open Graylog: and login with

  username: mgt
  password: graylog2

Step 2: Graylog2 Extension for Magento

We developed a magento extension for graylog2 which logs all errors and log messages in your graylog2.

Download the Graylog2 Magento Extension

Download Magento Extension


  • copy all files to your magento installation

Open app/Mage.php and add the following line

public static function run($code = '', $type = 'store', $options = array())
  } catch (Exception $e) {
    if (self::isInstalled() || self::$_isDownloader) {
    //add this line
    self::dispatchEvent('mage_run_exception',array('exception' =&gt; $e));
  • Clear the cache in Admin -> System -> Cache Management
  • Logout and Login to reload the ACL
  • Go to Admin -> System -> Configuration -> MGT-COMMERCE.COM -> Graylog -> Settings -> Active -> Yes
  • Enter your Graylog2 host
  • Have fun and give Feedback

Quick Access through your Dashboard
Quick Access through your Dashboard

Full Integration via Iframe
Full Integration via Iframe

Graylog2 Configuration
Graylog2 Configuration

5 responses to How to manage your Magento logs with Graylog2

  1. Is there something already written that actually sends data from Magento to graylog2? The module has nothing in it for actually logging exceptions and so on.

  2. Hallo Herr Wieczorek,
    eine Frage zur Extension – dazu kurz den Stand zu Magento:
    Zur Zeit arbeite ich auf einer lokalen Magento Installation – (Windows 7 , WAMP 2.1)
    Der Server und auch das Web Interface laufen nur unter einem Linux/Unix-System.
    EIne Konto bei Amazon AWS möchte ich vorerst nicht anlegen.
    Benötige ich den Server für die Extension, und wie kann ich es local ohne amazon testen
    Als Host habe ich localhost eingetragen und bekomme im Graylog Dashboard demzufolge
    das Frontend zu sehen.

    Vielen Dank

  3. Remember to also allow HTTP and HTTPS in your Security Group configuration, as well as SSH and All UPD connections.

Leave a Reply