1LOGGING(7)                                                          LOGGING(7)
2
3
4

NAME

6       Logging - Why, What & How We Log
7
8   Description
9       The  npm CLI has various mechanisms for showing different levels of in‐
10       formation back to end-users for certain commands, configurations &  en‐
11       vironments.
12
13   Setting Log File Location
14       All logs are written to a debug log, with the path to that file printed
15       if the execution of a command fails.
16
17       The default location of the logs directory is a directory  named  _logs
18       inside  the npm cache. This can be changed with the logs-dir config op‐
19       tion.
20
21       Log files will be removed from the logs-dir  when  the  number  of  log
22       files exceeds logs-max, with the oldest logs being deleted first.
23
24       To turn off logs completely set --logs-max=0.
25
26   Setting Log Levels
27   loglevel
28       loglevel  is  a global argument/config that can be set to determine the
29       type of information to be displayed.
30
31       The default value of loglevel is "notice" but there  are  several  lev‐
32       els/types of logs available, including:
33
34"silent"
35
36"error"
37
38"warn"
39
40"notice"
41
42"http"
43
44"timing"
45
46"info"
47
48"verbose"
49
50"silly"
51
52
53       All  logs  pertaining to a level proceeding the current setting will be
54       shown.
55
56   Aliases
57       The log levels listed above have various corresponding aliases, includ‐
58       ing:
59
60-d: --loglevel info
61
62--dd: --loglevel verbose
63
64--verbose: --loglevel verbose
65
66--ddd: --loglevel silly
67
68-q: --loglevel warn
69
70--quiet: --loglevel warn
71
72-s: --loglevel silent
73
74--silent: --loglevel silent
75
76
77   foreground-scripts
78       The  npm  CLI  began hiding the output of lifecycle scripts for npm in‐
79       stall as of v7. Notably, this means you will not see  logs/output  from
80       packages  that  may  be  using "install scripts" to display information
81       back to you or from your own project's scripts defined in package.json.
82       If  you'd  like  to  change this behavior & log this output you can set
83       foreground-scripts to true.
84
85   Timing Information
86       The --timing config can be set which does two things:
87
88       1. Always shows the full path to the debug log  regardless  of  command
89          exit status
90
91       2. Write timing information to a timing file in the cache or logs-dir
92
93
94       This  file is a newline delimited list of JSON  objects that can be in‐
95       spected to see timing data for each task in a npm CLI run.
96
97   Registry Response Headers
98   npm-notice
99       The npm CLI reads from & logs any npm-notice headers that are  returned
100       from the configured registry. This mechanism can be used by third-party
101       registries to provide useful  information  when  network-dependent  re‐
102       quests occur.
103
104       This  header  is  not  cached, and will not be logged if the request is
105       served from the cache.
106
107   Logs and Sensitive Information
108       The npm CLI makes a best effort to redact the following  from  terminal
109       output and log files:
110
111       • Passwords inside basic auth URLs
112
113       • npm tokens
114
115
116       However,  this  behavior  should  not be relied on to keep all possible
117       sensitive information redacted. If you are concerned about  secrets  in
118       your  log  file  or  terminal output, you can use --loglevel=silent and
119       --logs-max=0 to ensure no logs are written to your terminal or filesys‐
120       tem.
121
122   See also
123       • npm help config
124
125
126
127
128                                September 2022                      LOGGING(7)
Impressum