Azure App Insights 不从 winston 收集日志
Azure App Insights not collecting log from winston
我有一个示例 NodeJS 应用程序正在尝试登录到 Azure Application Insights。当我 运行,应用程序成功登录到控制台但 Azure App Insights 没有捕获,无论是在本地 运行ning 还是在托管的 Azure 应用程序服务上。它只捕获 console.log 的输出,但不捕获 winston 的输出。请指教
应用程序日志文件系统已在 Azure 应用服务上启用并设置为调试级别
温斯顿:版本 3.3.3
applicationinsights:版本 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);
logger.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
原来 applicationInsights
是在我的演示项目 winston
之后导入的
我有一个示例 NodeJS 应用程序正在尝试登录到 Azure Application Insights。当我 运行,应用程序成功登录到控制台但 Azure App Insights 没有捕获,无论是在本地 运行ning 还是在托管的 Azure 应用程序服务上。它只捕获 console.log 的输出,但不捕获 winston 的输出。请指教
应用程序日志文件系统已在 Azure 应用服务上启用并设置为调试级别
温斯顿:版本 3.3.3
applicationinsights:版本 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);
logger.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
原来 applicationInsights
是在我的演示项目 winston
之后导入的