You probably know that MarkLogic Server logs important events
ErrorLog.txt file. By default it logs events at
INFO or higher,
but many development and staging environments change the
DEBUG. These log levels are also available to the
and some of your XQuery code might use that for
You might even know that MarkLogic also sends important events
to the operating system. On linux this means
syslog, and important events
are those at
NOTICE and higher by default.
But are you monitoring these events?
How can you set up your MarkLogic deployment so that it will automatically alert you to errors, warnings, or other important events?
Most linux deployments now use
rsyslog as their system logging facility.
The full documentation is available,
but this brief tutorial will show you how to set up email alerts for MarkLogic
rsyslog version 4.2.6.
All configuration happens in
Here is a sample of what we need for email alerts.
First, at the top of the file you should see several
ommail and add it if needed.
$ModLoad ommail.so # email support
Next, add a stanza for MarkLogic somewhere after the
# MarkLogic $template MarkLogicSubject,"Problem with MarkLogic on %hostname%" $template MarkLogicBody,"rsyslog message from MarkLogic:\r\n[%timestamp%] %app-name% %pri-text%:%msg%" $ActionMailSMTPServer 127.0.0.1 $ActionMailFrom your-address@your-domain $ActionMailTo your-address@your-domain $ActionMailSubject MarkLogicSubject #$ActionExecOnlyOnceEveryInterval 3600 daemon.notice :ommail:;MarkLogicBody
Be sure to replace both instances of
with an appropriate value. The ActionMailSMTPServer must be smart enough
to deliver email to that address. I used a default
on the local host, but you might choose to connect to a different host.
Note that I have commented out the
The author of
rsyslog, Rainer Gerhards,
recommends setting this value to a reasonably high number of seconds
so that your email inbox is not flooded with messages.
rsyslog documentation states that excess messages
are discarded, and I did not want to lose any important messages.
What I would really like to do is buffer messages for N seconds at a time,
and merge them together in one email.
rsyslog has many features, and does offer buffering,
it does not seem to know how to combine consecutive messages
into a single email.
Getting back to what
rsyslog can do,
you can customize the subject and body of the mail message.
With the configuration above, a restart of the server
might send you an email like this one:
Subject: Problem with MarkLogic on myhostname.mydomain rsyslog message from MarkLogic: [May 17 23:58:36] MarkLogic daemon.notice<29>: Starting MarkLogic Server 5.0-3 i686 in /opt/MarkLogic with data in /var/opt/MarkLogic
When making any
rsyslog changes, be sure to restart the service:
sudo service rsyslog restart
At the same time, check your system log for any errors or typos.
This is usually
The full documentation for template substitution properties
You can also read about a wealth of other options available in