2017 © Pedro Peláez
 

library monolog-mssql

A handler for Monolog that sends messages to MSSQL

image

jkey/monolog-mssql

A handler for Monolog that sends messages to MSSQL

  • Sunday, June 3, 2018
  • by jkey
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 48 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

monolog-mssql

Microsoft SQL Server Handler for Monolog, which allows to store log messages in a MSSQL Table. It can log text messages to a specific table. The class further allows to use extra attributes as database field, which are can be used for later analyzing and sorting., (*1)

This is a fork from waza-ari/monolog-mysql, with some changes. The table and columns are not created or removed automatically., (*2)

Installation

monolog-mssql is available via composer. Just add the following line to your required section in composer.json and do a php composer.phar update., (*3)

"jkey/monolog-mssql": ">1.0.0"

After that you have to create your database table. We need the following structure, which you are free to extend., (*4)

CREATE TABLE myLog
  (
    id         BIGINT        NOT NULL
                             IDENTITY(1,1)
                             PRIMARY KEY,
    channel    NVARCHAR(255) NOT NULL,
    level      INT           NOT NULL,
    message    NTEXT         NOT NULL,
    time       INT           NOT NULL
  );

Usage

Just use it as any other Monolog Handler, push it to the stack of your Monolog Logger instance. The Handler however needs some parameters:, (*5)

  • $pdo PDO Instance of your database. Pass along the PDO instantiation of your database connection with your database selected.
  • $table The table name where the logs should be stored
  • $additionalFields simple array of additional database fields, which should be stored in the database. The fields can later be used in the extra context section of a record. See examples below. _Defaults to an empty array()
  • $level can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. _ Defaults to Logger::DEBUG_
  • $bubble _Defaults to true

Examples

Given that $pdo is your database instance, you could use the class as follows:, (*6)

<?php
require __DIR__ . '/../vendor/autoload.php';
//Import class
use Monolog\Logger;
use Jkey\Monolog\Handler\MSSQLHandler;

$pdo = new PDO('sqlsrv:Server=localhost;Database=log', 'myuser', 'mypass');

//Create logger
$log = new Logger('name');
$log->pushHandler(new MSSQLHandler($pdo, "log", array('username', 'userid'), \Monolog\Logger::DEBUG));

//Now you can use the logger, and further attach additional information
$log->addWarning("This is a great message, woohoo!", array('username'  => 'John Doe', 'userid'  => 245));

License

This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information., (*7)

The Versions

03/06 2018

dev-master

9999999-dev https://github.com/jkey/monolog-mssql

A handler for Monolog that sends messages to MSSQL

  Sources   Download

MIT

The Requires

 

by Kurt Seiler

database log logging monolog mssql sqlsrv

03/06 2018

v1.0.5.1

1.0.5.1 https://github.com/jkey/monolog-mssql

A handler for Monolog that sends messages to MSSQL

  Sources   Download

MIT

The Requires

 

by Kurt Seiler

database log logging monolog mssql sqlsrv

03/06 2018

1.0.5

1.0.5.0 https://github.com/jkey/monolog-mssql

A handler for Monolog that sends messages to MSSQL

  Sources   Download

MIT

The Requires

 

by Kurt Seiler

database log logging monolog mssql sqlsrv

23/04 2017

dev-development

dev-development https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Herrmann

database log logging monolog mysql

13/02 2017

v1.0.4

1.0.4.0 https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

by Daniel Herrmann

database log logging monolog mysql

13/07 2015

v1.0.3

1.0.3.0 https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

by Daniel Herrmann

database log logging monolog mysql

16/02 2015

v1.0.2

1.0.2.0 https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

by Daniel Herrmann

database log logging monolog mysql

25/11 2014

v1.0.1

1.0.1.0 https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

by Daniel Herrmann

database log logging monolog mysql

13/09 2014

v1.0.0

1.0.0.0 https://github.com/waza-ari/monolog-mysql

A handler for Monolog that sends messages to MySQL

  Sources   Download

MIT

The Requires

 

by Daniel Herrmann

database log logging monolog mysql