https://github.com/xseman/log4js-appender-sentry
Log4js Sentry appender
https://github.com/xseman/log4js-appender-sentry
appender log4js log4js-node logger sentry
Last synced: about 1 year ago
JSON representation
Log4js Sentry appender
- Host: GitHub
- URL: https://github.com/xseman/log4js-appender-sentry
- Owner: xseman
- License: apache-2.0
- Created: 2023-06-21T17:48:03.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T20:15:44.000Z (over 1 year ago)
- Last Synced: 2025-03-02T06:04:26.265Z (about 1 year ago)
- Topics: appender, log4js, log4js-node, logger, sentry
- Language: TypeScript
- Homepage: https://npm.im/log4js-appender-sentry
- Size: 93.8 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# log4js appender - Sentry
Sends logging events to Sentry. This appender integrates
[@sentry/node][sentry_javascript].
[sentry_javascript]: https://github.com/getsentry/sentry-javascript

## Installation
**npm registry**
```sh
npm install log4js-appender-sentry
```
## Configuration
### TypeScript
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.
```ts
import "log4js-appender-sentry";
```
### Example
```ts
import log4js from "log4js";
import "log4js-appender-cloudwatch";
log4js.configure({
appenders: {
sentry: {
type: "log4js-appender-sentry",
dsn: "",
user: {
// ...
},
},
},
categories: {
default: {
level: "debug",
appenders: [
"sentry",
],
},
},
});
const log = log4js.getLogger();
// ...
```
## Options
Sentry is mainly used to report application errors so the default log level is
`WARN` and above, other log levels will be ignored.
### type
_Required_\
Type: log4js-appender-sentry
The type of the appender. Must be set to `log4js-appender-sentry`.
### dsn
_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][sentry_dsn] for more details on DSN.
[sentry_dsn]: https://docs.sentry.io/product/sentry-basics/dsn-explainer/
### user
_Optional_\
Type: `User`
```ts
// 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][sentry_user].
[sentry_user]: https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/