Sends logging events to Sentry. This appender integrates @sentry/node.
npm registry
npm install log4js-appender-sentry
If you're using TypeScript, importing this library as a side effect will
automatically merge the log4js interface Appenders
. This merging enables
autocomplete for the appenders configuration, providing convenient access to its
properties.
import "log4js-appender-sentry";
import log4js from "log4js";
import "log4js-appender-cloudwatch";
log4js.configure({
appenders: {
sentry: {
type: "log4js-appender-sentry",
dsn: "<config>",
user: {
// ...
},
},
},
categories: {
default: {
level: "debug",
appenders: [
"sentry",
],
},
},
});
const log = log4js.getLogger();
// ...
Sentry is mainly used to report application errors so the default log level is
WARN
and above, other log levels will be ignored.
Required
Type: log4js-appender-sentry
The type of the appender. Must be set to log4js-appender-sentry
.
Required
Type: string
A DSN (Data Source Name) specifies where the Sentry SDK should send events, ensuring they are associated with the correct project. Refer to the Sentry documentation for more details on DSN.
Optional
Type: User
// import { User } from "@sentry/node/types";
interface User {
[key: string]: any;
id?: string;
ip_address?: string;
email?: string;
username?: string;
segment?: string;
}
User data used for scope configuration. For additional information, see the Sentry user documentation.