az-bunyan provides azure storage streams for bunyan logger.
npm install az-bunyan --save
- Create the stream
// define the target azure storage table name
const tableName = 'destinationTableName';
// define the connection string to your azure storage account
const connectionString = 'DefaultEndpointsProtocol=https;AccountName=storageAccountName;AccountKey=storageAccoutnKey;'
// initialize the az-bunyan table storage stream
const azureStream = azBunyan.createTableStorageStream('warning', {
connectionString: connectionString,
tableName: tableName
});
- Add the stream to your bunyan logger
const logger = bunyan.createLogger({
name: "yourLoggerName",
streams: [
azureStream
]
});
PartitionKey and rowKey are very important concepts of azure storage. Planning your your key strategy is very important to ensure queryability and scalability of your logs. We suggest that you read this documentation.
Az-bunyan comes with a default rowKey and partitionKey strategy, but we don't believe in the one size fits all when it comes to that kind of point. So when you create your stream you can give custom key generation templates.
The templates are compiled with handlerbars so you should follow handlebars syntax.
const azureStream = azBunyan.createTableStorageStream('warning', {
connectionString: connectionString,
tableName: tableName
partitionKeyFormat: "{{name}}_{{momentFormat time "YYYY-MM-DD"}}"
rowKeyFormat: "{{#if correlationId}}{{correlationId}}{{else}}{{newId}}{{/if}}"
});
- Since azure table only supports column names composed of alpha numeric characters, az-bunyan drops those characters from property names. You should avoid logging an object with property names which differ only by special characters.
- Blob Storage support
- Log rotation support
Feel free to suggest features or submit pull requests.