winston-azure-blob

NEW winston transport for azure blob storage

Usage no npm install needed!

<script type="module">
  import winstonAzureBlob from 'https://cdn.skypack.dev/winston-azure-blob';
</script>

README

winston-azure-blob

An Azure Blob transport for winston3

NPM

Highlights

  • Simple API
  • Typescript ready
  • SAS support
  • Highly configurable

Installation

yarn install winston
yarn install winston-azure-blob

Usage

  import * as winston from "winston";
  import { winstonAzureBlob } from "winston-azure-blob";

  const logger = winston.createLogger({
    format: winston.format.combine(
        winston.format.timestamp(),
        winston.format.splat(),
        winston.format.json()
    ),
    transports: [
      winstonAzureBlob({
        account: {
          name: "Azure storage account sub domain ([A-Za-z0-9])",
          key: "The long Azure storage secret key"
          // or 
          host: 'The host address',
          sasToken: 'The Shared Access Signature token'
        },
        containerName: "A container name",
        blobName: "The name of the blob",
        level: "info",
        bufferLogSize : 1,
        syncTimeout : 0,
        rotatePeriod : "",
        eol : "\n"
      })
    ]
  });
  
  logger.warn("Hello!");

The winstonAzureBlob transport accepts the following options:

  • level: Level of messages that this transport should log (defaults to info).
  • account.name: The name of the Windows Azure storage account to use
  • account.key: The access key used to authenticate into this storage account
  • blobName: The name of the blob to log
  • containerName: The container which will contain the logs
  • eol: The character append to each log (By default a carriage return)
  • rotatePeriod: A moment format ex : YYYY-MM-DD will generate blobName.2000.01.01
  • bufferLogSize: A minimum number of logs before sync the blob, set to 1 if you want sync at each log
  • syncTimeout: The maximum time between two sync, set to zero if you don't want

Inspiration

https://github.com/sdnetwork/winston3-azureblob-transport