https://signoz.io logo
#general
Title
# general
s

shridhar g kanagond

06/06/2023, 4:42 AM
Hi #general we are trying to send logs to signoz through winston logs in localhost , i used the below code to send logs as mentioned in the logs
Copy code
const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api')
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ConsoleSpanExporter, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');

const memoryExporter = new InMemorySpanExporter();
const provider = new NodeTracerProvider();
provider.register();
const tracer = provider.getTracer('default');
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
registerInstrumentations({
  instrumentations: [
    new WinstonInstrumentation({
      enabled: true,
      logHook: (_span, record) => {
        record['resource.service.name'] = 'testLogs';
      },
    }),
  ],
});

const winston = require('winston');

const logger = winston.createLogger({
  transports: [
    new winston.transports.Console(),
    new winston.transports.Http({
      host: 'localhost',
      port: 3301,
      path: '/api/v1/logs',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      }
    })
  ],
})

function main() {
  tracer.startActiveSpan('main', (span) => {
    <http://logger.info|logger.info>("Started the span, printing context");
    <http://logger.info|logger.info>(span.spanContext());
    <http://logger.info|logger.info>("In main main spanning");
    require('./app.js')
  });
  <http://logger.info|logger.info>("Ended span in main");
}

main();
but not able to see the logs , is there anything i'm missing. if anyone can help me will be great. looking forward for the support from team. running signoz with ./install.sh on localhost port 3301 and node application running on localhost port 5555
s

Srikanth Chekuri

06/06/2023, 7:46 AM
``` host: 'localhost',
port: 3301,
path: '/api/v1/logs',```
This is not the correct host:port/path address. The correct one is
localhost:4318/v1/logs
. Even if that is fixed, it won’t probably work because the data has to be serialised using the OTLP protocol. I think one way you can do this is to write to file and use the filereceiver to collector logs.
3 Views