Chung-Yuan Hung
07/08/2024, 8:22 AMlogExporter, err := otlploggrpc.New(context.Background(),
otlploggrpc.WithEndpoint(collectorURL),
)
if err != nil {
// handle error
}
processor := log.NewBatchProcessor(logExporter)
logProvider = log.NewLoggerProvider(
log.WithResource(resources),
log.WithProcessor(processor),
)
global.SetLoggerProvider(logProvider)
slog.SetDefault(otelslog.NewLogger("app_name", otelslog.WithLoggerProvider(logProvider)))
// somewhere in the code base
<http://slog.Info|slog.Info>("some logs")
I'm expecting to see the logs in SigNoz dashboard but didn't see them.
I saw there's official document suggesting exporting log using log file, is that the only way ?
thanks for the helpNitish
07/08/2024, 8:38 AMfilelog/app
receiver.Chung-Yuan Hung
07/08/2024, 9:02 AMNitish
07/08/2024, 9:13 AMNitish
07/08/2024, 9:13 AMChung-Yuan Hung
07/08/2024, 9:15 AMOTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
environment variableNitish
07/08/2024, 9:15 AMChung-Yuan Hung
07/08/2024, 9:16 AMHossain Mahmud
07/08/2024, 9:54 AMChung-Yuan Hung
07/08/2024, 11:06 AMHossain Mahmud
07/08/2024, 11:40 AMYury Kozlov
08/14/2024, 2:18 AMlogExporter, err := otlploggrpc.New(ctx, otlploggrpc.WithGRPCConn(conn))
an example grpcs connection:
conn, _ := grpc.NewClient("1.2.3.4:4317", grpc.WithTransportCredentials(insecure.NewCredentials()))
an example of log submission:
logRecord := &otellog.Record{}
logRecord.SetTimestamp(time.Now())
logRecord.SetSeverity(otellog.SeverityError)
logRecord.SetBody(otellog.StringValue("busy doing hard work"))
logger.Emit(ctx, *logRecord)