Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (65 sloc) 2.46 KB

Logging to Logstash

Logstash is often used for log centralization and analysis. This cookbook describes how to set up Zotonic for logging to Logstash over UDP. As mentioned in the :ref:`Logging chapter <dev-logging>`, Zotonic uses the Lager framework. So we will change Zotonic’s Logstash configuration in order to send messages to Logstash.

Step 1: install a Logstash handler

First, you need to install a Logstash handler for Lager, for instance this one. To do so, add it (and the jsx JSON library) as a :ref:`dependency <deps>` in the rebar.config of your Zotonic site or module:

And recompile Zotonic to install the dependencies.

Step 2: configure the Logstash handler

The next step is to tell the Logstash handler where it should send its messages to:

Step 3: Logstash configuration

You need to configure your Logstash server so it can receive messages from Zotonic. A simple configuration should suffice:

You should now find all Zotonic log messages in Logstash. To test this, just call:

lager:error("Just testing the Logstash setup here!").
.. seealso:: the :ref:`dev-logging` chapter in the Developer Guide.