Azure App Insights не собирает журнал из Winston - PullRequest
1 голос
/ 14 июля 2020

У меня есть пример приложения NodeJS, которое пытается войти в Azure Application Insights. Когда я запускаю, приложение успешно регистрируется на консоли, но Azure App Insights не записывается ни при локальном запуске, ни в размещенной Azure службе приложений. Он захватывает только вывод console.log, но не winston. Пожалуйста, сообщите

Файловая система журнала приложений уже включена и установлена ​​на уровень отладки на Azure Служба приложений

enter image description here

winston: version 3.3.3

applicationinsights: version 1.8.2

введите описание изображения здесь

приложение js

const http = require('http');
const logger = require('./logger')
const appInsight = require('applicationinsights')

appInsight.setup('<MY INSTRUMENTATION KEY>')
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true, true)
.setSendLiveMetrics(false)
.setDistributedTracingMode(appInsight.DistributedTracingModes.AI)
.start()
const server = http.createServer((request, response) => {
    console.log('Console can be logged')
    logger.info('Winston info')
    logger.debug('Winston debug')
    logger.error('Winston error')
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.end("Hello World!");
});

const port = process.env.PORT || 1337;
server.listen(port);
console.log("Server running at http://localhost:%d", port);

регистратор. js

const winston = require("winston");

const level = process.env.LOG_LEVEL || 'debug';

const logger = winston.createLogger({
    transports: [
        new winston.transports.Console({
            level: level,
            format: winston.format.simple(),
            debugStdout: true,
        })
    ]
});

module.exports = logger

1 Ответ

0 голосов
/ 19 июля 2020

Оказалось, что applicationInsights был импортирован после winston в моем демонстрационном проекте

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...