4

Azure Application Insights にログを記録しようとしているサンプル NodeJS アプリケーションがあります。実行すると、アプリは正常にコンソールにログを記録しますが、Azure App Insights は、ローカルで実行されている場合でも、ホストされている Azure App Service で実行されている場合でもキャプチャしません。console.log の出力のみをキャプチャし、winston の出力はキャプチャしません。お知らせ下さい

アプリケーション ログ ファイル システムは既に有効になっており、Azure App Service でデバッグ レベルに設定されています

ここに画像の説明を入力

ウィンストン: バージョン 3.3.3

アプリケーションインサイト: バージョン 1.8.2

ここに画像の説明を入力

app.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
4

1 に答える 1