小编Joe*_*Joe的帖子

将 Azure 应用程序见解 sdk 与 NestJS 记录器结合使用时出现问题

在我们的nestjs应用程序中,我们尝试使用多个记录器,一个使用nestjs中的Logger,另一个是Azure Application Insight client.trackTrace。当两个记录器被调用时,我看到以下错误 1: 0x10003c597 node::Abort() [/usr/local/bin/node] 2: 0x1000bc617 node::Chdir(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node] 3: 0x10023663f v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/usr/local/bin/node] 4: 0x100235b81 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node] 5: 0x100235220 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node] 6: 0x3196422dbe3d Abort trap: 6

如果只使用一个记录器,那么没有问题,两者都可以单独工作。

如果将 Nestjs Logger 替换为调用 console.log、console.error ..etc 或 process.env.stdout.write(..) 的记录器,则它可以正常工作。因此,nestjs Logger 和 AppicationInsights 客户端之间似乎发生了一些事情。

创建记录器的工厂

import * as appInsights from 'applicationinsights';
import {Logger, LoggerService} from '@nestjs/common';



  appInsights
    .setup()
    .setAutoCollectConsole(true, true)
    .setAutoDependencyCorrelation(true)
    .start();



export const getLogger = (prefix: string): LoggerService => {


    const …
Run Code Online (Sandbox Code Playgroud)

typescript azure-application-insights nestjs

4
推荐指数
1
解决办法
3486
查看次数