1- # Sentry log4js appender
1+ # log4js appender - Sentry
22
33Sends logging events to Sentry. This appender integrates
44[ @sentry/node ] [ sentry_javascript ] .
55
6+ [ sentry_javascript ] : https://github.com/getsentry/sentry-javascript
7+
68## Installation
79
810** npm registry**
@@ -11,63 +13,92 @@ Sends logging events to Sentry. This appender integrates
1113npm install log4js-appender-sentry
1214```
1315
14- ## Options
16+ ## Configuration
1517
16- The [ ` SentryAppender ` ] [ internal_types ] interface extends the ` NodeClientOptions `
17- interface and provides additional options specific to the Node Sentry appender
18- SDK.
18+ ### TypeScript
19+
20+ If you're using TypeScript, importing this library as a side effect will
21+ automatically merge the log4js interface ` Appenders ` . This merging enables
22+ autocomplete for the appenders configuration, providing convenient access to its
23+ properties.
24+
25+ ``` ts
26+ import " log4js-appender-sentry" ;
27+ ```
28+
29+ ### Example
30+
31+ ``` ts
32+ import log4js from " log4js" ;
33+
34+ import " log4js-appender-cloudwatch" ;
35+
36+ log4js .configure ({
37+ appenders: {
38+ sentry: {
39+ type: " log4js-appender-sentry" ,
40+ dsn: " <config>" ,
41+ user: {
42+ // ...
43+ },
44+ },
45+ },
46+ categories: {
47+ default: {
48+ level: " debug" ,
49+ appenders: [
50+ " sentry" ,
51+ ],
52+ },
53+ },
54+ });
55+
56+ const log = log4js .getLogger ();
57+ // ...
58+ ```
59+
60+ ## Options
1961
2062Sentry is mainly used to report application errors so the default log level is
2163` WARN ` and above, other log levels will be ignored.
2264
23- ** ` type ` **
65+ ### type
2466
25- The type of the appender, must be set to ` log4js-appender-sentry ` .
67+ _ Required_ \
68+ Type: log4js-appender-sentry
2669
27- ** ` dsn ` **
70+ The type of the appender. Must be set to ` log4js-appender-sentry ` .
2871
29- A DSN tells a Sentry SDK where to send events so the events are associated with
30- the correct project. See [ documentation] [ sentry_dsn ] .
72+ ### dsn
3173
32- ** ` user ` **
74+ _ Required_ \
75+ Type: ` string `
3376
34- User data for scope configuration. See [ documentation] [ sentry_user ] .
77+ A DSN (Data Source Name) specifies where the Sentry SDK should send events,
78+ ensuring they are associated with the correct project. Refer to the Sentry
79+ [ documentation] [ sentry_dsn ] for more details on DSN.
3580
36- ## Configuration
81+ [ sentry_dsn ] : https://docs.sentry.io/product/sentry-basics/dsn-explainer/
3782
38- ** TypeScript **
83+ ### user
3984
40- If you're using TypeScript, importing this library as a side effect will
41- automatically merge the log4js interface ` Appenders ` . This merging enables
42- autocomplete for the appenders configuration, providing convenient access to its
43- properties.
85+ _ Optional_ \
86+ Type: ` User `
4487
4588``` ts
46- import " log4js-appender-sentry"
47- ```
48-
49- ** example**
50-
51- ``` json {3-6, 12}
52- {
53- "appenders" : {
54- "sentry" : {
55- "type" : " log4js-appender-sentry" ,
56- "dsn" : " ..."
57- }
58- },
59- "categories" : {
60- "default" : {
61- "level" : " debug" ,
62- "appenders" : [
63- " sentry"
64- ]
65- }
66- }
89+ // import { User } from "@sentry/node/types";
90+
91+ interface User {
92+ [key : string ]: any ;
93+ id? : string ;
94+ ip_address? : string ;
95+ email? : string ;
96+ username? : string ;
97+ segment? : string ;
6798}
6899```
69100
70- [ internal_types ] : ./index.d.ts
71- [ sentry_javascript ] : https://github.com/getsentry/sentry-javascript
101+ User data used for scope configuration. For additional information, see the
102+ Sentry user [ documentation] [ sentry_user ] .
103+
72104[ sentry_user ] : https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/
73- [ sentry_dsn ] : https://docs.sentry.io/product/sentry-basics/dsn-explainer/
0 commit comments