物业' Azure'类型'运输'不存在对于温斯顿

时间:2018-01-06 12:07:17

标签: node.js winston azure-blob-storage

    var winston = require("winston");
    require("winston-azure-blob-transport"); 
    var logger = new (winston.Logger)({
        transports: [
            new (winston.transports.AzureBlob)({
                account: {
                    name: "Azure storage account sub domain ([A-Za-z0-9])",
                    key: "The long Azure storage secret key"
                },
                containerName: "A container name",
                blobName: "The name of the blob",
                level: "info"
            })
        ]
    });
    logger.warn("Hello!");

我收到一个错误,即Property' Azure'类型'运输'不存在

1 个答案:

答案 0 :(得分:0)

我仍然无法使用您提供的代码重现此问题。

这是我的package.json文件:

{
  "name": "testwinston",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "winston": "^2.4.0",
    "winston-azure-blob-transport": "^0.2.6",
    "winston-daily-rotate-file": "^1.7.2", 
    "winston-express-middleware": "^0.1.0"
  }
}

这是我正在使用的代码:

var winston = require("winston");
require("winston-azure-blob-transport"); 

var logger = new (winston.Logger)({
    transports: [
        new (winston.transports.AzureBlob)({
            account: {
                name: "<my storage account name>",
                key: "my account key"
            },
            containerName: "test-container",
            blobName: "testlog.txt",
            level: "info"
        })
    ]
});
logger.warn("Hello!");

然后将使用以下内容创建blob文件:

enter image description here