danny8002 / log4js-azure-append-blob-appender

log4js appender that write log to Azure Storage (append blob)
1 stars 1 forks source link

log4js-azure-append-blob-appender

Built with Grunt Build Status Coverage Status NPM version Write log to Microsoft Azure Storage (append blob)

You should know when use this appender

Getting Started

installation

npm install log4js --save
npm install log4js-azure-append-blob-appender --save

usage:

This appender is compitable with log4js configuration file. for example, in your log4js configuration file (log4js.cfg.json)

{
    "appenders": [
        {
            "type": "console"
        },
        {
            "type": "log4js-azure-append-blob-appender",
            "category": "YOUR_CATEGORY",
            "azureStorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=YOUR_ACCOUNT;AccountKey=YOUR_KEY",
            "container": "log4test",
            "appendBlob": "my.log",
            "layout": {
              "type":"basic"
            }
        }
    ],
    "replaceConsole": true
}
    var log4js = require('log4js');
    var cfg = require("./log4js.cfg.json");
    log4js.configure(cfg);

    var log = log4js.getLogger("YOUR_CATEGORY");

    log.debug("my msg", "data1");

About Configuration

Required configuration item

Best Practice about this appender

Write json (instead of plain text) as every log line, so you can do more things (eg. use HDInsight to analyse log)

Update log