You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: deps/npm/docs/content/using-npm/logging.md
+30-3
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,24 @@
1
1
---
2
2
title: Logging
3
3
section: 7
4
-
description: Why, What & How we Log
4
+
description: Why, What & How We Log
5
5
---
6
6
7
7
### Description
8
8
9
9
The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments.
10
10
11
+
### Setting Log File Location
12
+
13
+
All logs are written to a debug log, with the path to that file printed if the execution of a command fails.
14
+
15
+
The default location of the logs directory is a directory named `_logs` inside the npm cache. This can be changed
16
+
with the `logs-dir` config option.
17
+
18
+
Log files will be removed from the `logs-dir` when the number of log files exceeds `logs-max`, with the oldest logs being deleted first.
19
+
20
+
To turn off logs completely set `--logs-max=0`.
21
+
11
22
### Setting Log Levels
12
23
13
24
#### `loglevel`
@@ -28,8 +39,6 @@ The default value of `loglevel` is `"notice"` but there are several levels/types
28
39
29
40
All logs pertaining to a level proceeding the current setting will be shown.
30
41
31
-
All logs are written to a debug log, with the path to that file printed if the execution of a command fails.
32
-
33
42
##### Aliases
34
43
35
44
The log levels listed above have various corresponding aliases, including:
@@ -47,6 +56,15 @@ The log levels listed above have various corresponding aliases, including:
47
56
48
57
The `npm` CLI began hiding the output of lifecycle scripts for `npm install` as of `v7`. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in `package.json`. If you'd like to change this behavior & log this output you can set `foreground-scripts` to `true`.
49
58
59
+
### Timing Information
60
+
61
+
The `--timing` config can be set which does two things:
62
+
63
+
1. Always shows the full path to the debug log regardless of command exit status
64
+
1. Write timing information to a timing file in the cache or `logs-dir`
65
+
66
+
This file is a newline delimited list of JSON objects that can be inspected to see timing data for each task in a `npm` CLI run.
67
+
50
68
### Registry Response Headers
51
69
52
70
#### `npm-notice`
@@ -55,6 +73,15 @@ The `npm` CLI reads from & logs any `npm-notice` headers that are returned from
55
73
56
74
This header is not cached, and will not be logged if the request is served from the cache.
57
75
76
+
### Logs and Sensitive Information
77
+
78
+
The `npm` CLI makes a best effort to redact the following from terminal output and log files:
79
+
80
+
- Passwords inside basic auth URLs
81
+
- npm tokens
82
+
83
+
However, this behavior should not be relied on to keep all possible sensitive information redacted. If you are concerned about secrets in your log file or terminal output, you can use `--loglevel=silent` and `--logs-max=0` to ensure no logs are written to your terminal or filesystem.
0 commit comments