Skip to content

Cannot see severity level info in application insights using winston #1410

@ollesve

Description

@ollesve

Hello there!

Im running:
winston 3.14.2
applicationinsights 3.4.0
node 22.9.0

When running this:

import * as appInsights from 'applicationinsights'


try {
  appInsights
    .setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING)
    .setAutoCollectRequests(true)
    .setAutoCollectPerformance(true, true)
    .setAutoCollectExceptions(true)
    .setAutoCollectDependencies(true)
    .setAutoCollectConsole(true, true)
    .setAutoCollectPreAggregatedMetrics(true)
    .setSendLiveMetrics(false)
    .setInternalLogging(false, true)
    .enableWebInstrumentation(false)
    .start()
} catch (error) {
  console.error('Failed to initialize Application Insights:', error)
}

export const appInsightsClient = appInsights.defaultClient
import { appInsightsClient } from './utils/appInsights'
import { logger } from './utils/logger'
import { createLogger, transports } from 'winston'

const logger2 = createLogger({
  transports: [new transports.Console()],
})

async function test() {
  logger2.info('Info Test')
  logger2.warn('Warn Test')
  logger2.error('Error Test')
  logger.info('Info Test my logger')
  logger.warn('Warn Test my logger')
  logger.error('Error Test my logger')
  appInsightsClient.trackTrace({
    message: 'Info Test SDK',
    severity: 'Information',
  })
  console.log('Info Test console')
  await appInsightsClient.flush()
}

test()

I get this result in application insights:

Image

Any ideas on what might be the issue here?

Thank you for taking the time! :))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions