-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
10.20.0
Framework Version
Pino 10.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
PinoIntegration and enableLogs:true are set in the SDK initialisation
Two code examples.
From a Discord thread.
// Internal log method with type-safe logging
private log(level: LogLevel, message: string, data?: any) {
const parsedData = this.safeJson(data); // Parse data to JSON
const logEntry: StandardLog = {
level,
timestamp: dateNow(),
requestId: this.requestId,
message,
userId: this.userId,
data: parsedData === null ? undefined : parsedData, // Set data if parsedData is not null
};
// Use the correct Pino method based on the log level
switch (level) {
case "trace":
this.logger.trace(logEntry);
break;
case "debug":
this.logger.debug(logEntry);
break;
case "info":
this.logger.info(logEntry);
break;
case "warn":
this.logger.warn(logEntry);
break;
case "error":
this.logger.error(logEntry);
break;
case "fatal":
this.logger.fatal(logEntry);
break;
default:
this.logger.info(logEntry); // Default to info if level is not recognized
break;
}
}
From an internal support ticket :
The logger is set-up as a Sentry module.
export const PinoHttpModule = LoggerModule.forRootAsync({...})
@Module({...
PinoHttpModule,
...})
export class AppModule {
The app startup code:
const pinoLogger = app.get(PinoLogger);
app.useLogger(pinoLogger);
//Send the log
private readonly logger = new Logger(MyService.name);
...
this.logger.log('log msg');
Steps to Reproduce
Use the example codes above to send logs to Sentry.
Expected Result
Logs are sent to Sentry and visible on the logs page.
Actual Result
No logs are reported.
Quick tests with simple logs (logger.info("Info log")) are sent correctly. Might be an integration's limitation where more complex logs are dropped.
My example that works:
//instrument.js
const Sentry = require("@sentry/node");
Sentry.init({
debug:true,
dsn: "...",
integrations: [
Sentry.pinoIntegration({
log: { levels: ["info", "warn", "error"] }
})
],
enableLogs: true,
});
//script
require("./instrument");
const logger = require('pino')
logger.info('hello world')
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Community