Thursday 20 November 2014

MapGuide tidbits: Log monitoring with log.io

If the previous MapGuide log monitoring solution don't cut it for you (especially on Linux), here's another one you can try.

log.io is a real-time log monitoring solution that runs in your web browser. It is powered by node.js and socket.io.

Just a note before we dive in, this post is geared towards Linux-specific installations of MapGuide. This may or may not work for Windows. The log.io install instructions assume Linux, so we're rolling with that.

To install log.io you will first have to install node.js, there's a bajillion different links out there on how to install node.js, so here's one for:


Once node is installed, you can install the log.io package via npm (on Ubuntu you'll have to elevate that command with sudo):

npm install -g log.io --user "[username that will run log.io]"

Then start the log.io server.

log.io-server

Then create a harvester.conf in your ~/.log.io/ directory that defines what log files to monitor. Here's a basic example configured for MapGuide and Apache log monitoring.

exports.config = {
    nodeName: "mapguide_server",
    logStreams: {
      apache: [
        "/usr/local/mapguideopensource-2.6.0/webserverextensions/apache2/logs/access_log",
        "/usr/local/mapguideopensource-2.6.0/webserverextensions/apache2/logs/error_log"
      ],
      mapguide_access: [
        "/usr/local/mapguideopensource-2.6.0/server/Logs/Access.log"
      ],
      mapguide_error: [
        "/usr/local/mapguideopensource-2.6.0/server/Logs/Error.log"
      ]
    },
    server: {
      host: '0.0.0.0',
      port: 28777
    }
  } 

Now start the log harvester.

log.io-harvester

Now browse to http://localhost:28778 and watch your MapGuide log files in real time.


NOTE: The above install instructions were pilfered from the log.io website itself, however I found the global install option to be problematic on my Ubuntu test VM. For some reason it always insists on building the native modules as the "root" user and not the user I designated from the npm install command. So I went for a local install instead, which means the following commands have been changed to the following:

  • Installing log.io: npm install log.io
  • Running log.io server: ~/node_modules/log.io/bin/log.io-server
  • Running log.io harvester: ~/node_modules/log.io/bin/log.io-harvester

No comments: