LuaLogging logo
LuaLogging
A simple API to use logging features in Lua
home · manual · example · console · email · file · socket · sql

SQL appender

The SQL appender can be used to write log messages to a SQL database table. It relies on LuaSQL. As such any database supported by LuaSQL can be used.
function logging.sql{
  connectionfactory = function,
  [tablename = string,]
  [logdatefield = string,]
  [loglevelfield = string,]
  [logmessagefield = string,]
  [keepalive = boolean],
}

Example

require"logging.sql"
require"luasql.jdbc"

local env, err = luasql.jdbc('com.mysql.jdbc.Driver')

local logger = logging.sql {
                             connectionfactory = function()
                               local con, err = env:connect('jdbc:mysql://localhost/test', 'tcp', '123')
                               assert(con, err)
                               return con
                             end,
                             keepalive = true,
}

logger:info("logging.sql test")
logger:debug("debugging...")
logger:error("error!")


$Id: index.html,v 1.1 2004/11/16 16:33:10 tuler Exp $