-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlog4js.node.txt
57 lines (50 loc) · 4.23 KB
/
log4js.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
┏━━━━━━━━━━━━┓
┃ LOG4JS ┃
┗━━━━━━━━━━━━┛
ALTERNATIVES ==> #See winston
VERSION ==> #0.6.16
LOG4JS.configure(FILE|OBJ #FILE is a JSON file or OBJ with members:
[, OBJ2]) # - appenders OBJ3_ARR:
# - type STR and extra CONFIGVAR members depending on type. Available are:
# - "console": layout { type STR, ... } with:
# - "colored" (def)
# - "basicLayout" (same without colors)
# - "messagePassThroughLayout" (only the data, no colors)
# - "pattern", pattern: STR2 (format string,
# see online doc https://github.com/nomiddlename/log4js-node/wiki/Layouts)
# - "file", layout OBJ, filename STR, category STR, maxLogSize NUM (do rollout),
# backups NUM (for rollout)
# - "dateFile", filename STR, pattern STR2, alwaysIncludePattern BOOL: same but adds
# date format STR2 to end of filename (instead of rolling), except for most recent
# one (unless BOOL true)
# - "smtp": send email
# - "categoryFilter", appender OBJ, exclude STR2_ARR: same as using OBJ in
# appenders OBJ3_ARR but will only apply for categories not in STR2_ARR
# - "logLevelFilter", appender OBJ, level STR: same for levels >= STR
# - replaceConsole BOOL: if true (def: false), LOG4JS.getLogger() replace CONSOLE
#Can specify JSON file with ENVVAR LOG4JS_CONFIG too.
#Replaces current one (déf: [{ "console", layout: { "colored" } }])
#OBJ2 members:
# - reloadSecs NUM: watches FILE every NUM seconds (def: 60)
# - cwd DIR: relative path for "[dateF|f]ile"
LOG4JS.getLogger() #Returns a LOGGER (should do LOG4JS.configure() before)
LOGGER.trace|debug|info|warn| #Fires appender FUNC2(OBJ).
error|fatal(VAL) #With default appender, will print "[timestamp] [level] category - message" with colors
#Def. category is "[default]" (can be changed with LOGGER.category)
LOGGER.setLevel(LEVEL) #Filters message by level
CUSTOM APPENDERS ==> #To use custom appenders, create a MODULE (use "type" MODULE_STR) which defines:
# - exports.appender = FUNC(OBJ) -> FUNC2(OBJ4):
# - OBJ4 has members level OBJ5, categoryName STR, startTime DATE, data VAL, logger LOGGER
# - level OBJ5 has members level NUM (to compare numerically) and levelStr (e.g. "INFO")
# - OBJ are CONFIGVAR members
# - fired by LOGGER.*(VAL)
# - exports.configure = FUNC3(OBJ) -> FUNC()(OBJ) (so returns FUNC2(OBJ))
# (OBJ are CONFIGVAR members)
# - (optional) exports.shutdown = FUNC(CALLBACK()): fired at destruction
LOG4JS.connectLogger #Express MIDWR that logs requests using LOG4JS.
(LOGGER[, OBJ]) #OBJ:
# - format: what is printed, as MORGAN format string (def: same as MORGAN "default", without
# the date (since it is in the timestamp))
# - level: level used to log (def: "auto", meaning warn for 3**, error for 4** and 5**,
# info for 1** and 2**)
# - nolog REGEXP: don't log REQ.originalUrl that matches REGEXP