Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How to disable creating of verbose log files for every npm command? #4206

Closed
2 tasks done
mirocklez opened this issue Jan 4, 2022 · 4 comments · Fixed by #4594
Closed
2 tasks done

[QUESTION] How to disable creating of verbose log files for every npm command? #4206

mirocklez opened this issue Jan 4, 2022 · 4 comments · Fixed by #4594
Assignees
Labels
Awaiting Information further information is requested Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release

Comments

@mirocklez
Copy link

mirocklez commented Jan 4, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When I run any npm related command I got a new debug log file created, which is kinda annoying.
How can prevent the debug log files being created after each npm command?

Form example when I run npm -v, I got a new log file with the following output:

0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node/17.3.0/bin/node',
0 verbose cli   '/usr/local/bin/npm',
0 verbose cli   '-v'
0 verbose cli ]
1 info using npm@8.3.0
2 info using node@v17.3.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 3ms
6 timing config:load:builtin Completed in 5ms
7 timing config:load:cli Completed in 3ms
8 timing config:load:env Completed in 0ms
9 timing config:load:project Completed in 3ms
10 timing config:load:file:/Users/(protected)/.npmrc Completed in 1ms
11 timing config:load:user Completed in 2ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 1ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 16ms
18 timing npm:load:configload Completed in 17ms
19 timing npm:load:setTitle Completed in 2ms
20 timing config:load:flatten Completed in 2ms
21 timing npm:load:display Completed in 4ms
22 verbose logfile /Users/(protected)/.npm/_logs/2022-01-04T19_56_27_927Z-debug-0.log
23 timing npm:load:logFile Completed in 4ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 27ms
27 verbose exit 0
28 timing npm Completed in 316ms
29 info ok

When I start some node app with npm run dev (for example, some Nuxt.js app), again I got a new log file:

0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node/17.3.0/bin/node',
0 verbose cli   '/usr/local/bin/npm',
0 verbose cli   'run',
0 verbose cli   'dev'
0 verbose cli ]
1 info using npm@8.3.0
2 info using node@v17.3.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 3ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/(protected)/.../(protected)/.npmrc Completed in 2ms
10 timing config:load:project Completed in 5ms
11 timing config:load:file:/Users/(protected)/.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 17ms
19 timing npm:load:configload Completed in 17ms
20 timing npm:load:setTitle Completed in 3ms
21 timing config:load:flatten Completed in 3ms
22 timing npm:load:display Completed in 4ms
23 verbose logfile /Users/(protected)/.npm/_logs/2022-01-04T18_20_49_151Z-debug-0.log
24 timing npm:load:logFile Completed in 6ms
25 timing npm:load:timers Completed in 0ms
26 timing npm:load:configScope Completed in 0ms
27 timing npm:load Completed in 31ms

And so on - I got a new log file for every command, not only for errors or warnings.
My global .npmrc file has no extra settings.
Even if I add to it `loglevel=silent' I still have the new log files, but the info in the terminal is being cut off.

Any ideas to prevent these verbose log files being created and keep them only for errors and warning?

Expected Behavior

Not to have a verbose log file for each npm command.

Steps To Reproduce

No response

Environment

  • npm: 8.3.0
  • Node: 17.3.0 installed with HomeBrew
  • OS: MacOS
  • platform: MacBook Pro
  • npm config:

npm config ls:

; "builtin" config from /usr/local/lib/node_modules/npm/npmrc

prefix = "/usr/local"

; "user" config from /Users/(protected)/.npmrc
; node bin location = /usr/local/Cellar/node/17.3.0/bin/node
; cwd = /Users/(protected)
; HOME = /Users/(protected)

npm config ls -l:

; "default" config from default values

_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/Users/(protected)/.npm"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
ci-name = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "vi"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "/usr/local/etc/npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/Users/(protected)/.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "/Users/(protected)/.npm-init.js"
init.version = "1.0.0"
json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
node-version = "v17.3.0"
noproxy = [""]
npm-version = "8.3.0"
offline = false
omit = []
only = null
optional = null
otp = null
pack-destination = "."
package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "/usr/local/Cellar/node/17.3.0" ; overridden by builtin
preid = ""
production = null
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "/usr/local/bin/zsh"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/var/folders/hr/bbbmspwn0pbbhplv4jpt6vcc0000gn/T"
umask = 0
unicode = true
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "/Users/(protected)/.npmrc"
version = false
versions = false
viewer = "man"
which = null
workspace = []
workspaces = null
yes = null

; "builtin" config from /usr/local/lib/node_modules/npm/npmrc

prefix = "/usr/local"

; "user" config from /Users/(protected)/.npmrc

; "cli" config from command line options

long = true
@mirocklez mirocklez added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jan 4, 2022
@nlf
Copy link
Contributor

nlf commented Jan 4, 2022

we create a log file for every command we run to ensure we don't lose any context if an error does occur. this is not configurable. the loglevel configuration selects which messages get printed to your screen, not those that are written to disk.

if we were to disable this feature, we would have no means of providing a complete debug log when a command fails. we can't only create them when there's an error, because we don't know whether or not there's going to be an error when the log initially begins writing. our options are either to buffer the log messages in memory, which is unwise since debug logs can be rather large, or stream them to a file. we chose the latter. this also allows us to still get some debug log output if an unexpected crash occurs. older versions of npm buffer log messages in memory and write the file only when an error takes places, we had many scenarios that were difficult to debug due to the loss of context when failures happened before the log file could be written fully.

for what it's worth, the old log files should be removed the next time you run a command. if that's not happening, that would be a bug and we can look into it.

@nlf nlf added Awaiting Information further information is requested and removed Needs Triage needs review for next steps labels Jan 4, 2022
@nlf nlf self-assigned this Jan 4, 2022
@mirocklez
Copy link
Author

mirocklez commented Jan 5, 2022

@nlf - Thanks for clarifying this one.
Good to know and definitely makes sence for the whole process 👍

I can confirm that the old verbose log files are not being deleted.

lukekarrys added a commit that referenced this issue Mar 22, 2022
This also allows logs-max to be set to 0 to disable log file writing.

Closes #4466
Closes #4206
lukekarrys added a commit that referenced this issue Mar 23, 2022
This also allows logs-max to be set to 0 to disable log file writing.

Closes #4466
Closes #4206
lukekarrys added a commit that referenced this issue Mar 23, 2022
This also allows logs-max to be set to 0 to disable log file writing.

Closes #4466
Closes #4206
lukekarrys added a commit that referenced this issue Mar 23, 2022
This also allows logs-max to be set to 0 to disable log file writing.

Closes #4466
Closes #4206
fritzy pushed a commit that referenced this issue Mar 24, 2022
This also allows logs-max to be set to 0 to disable log file writing.

Closes #4466
Closes #4206
@lukekarrys
Copy link
Contributor

The debug log can now be disabled with the config --logs-max=0

@7ochem
Copy link

7ochem commented Feb 9, 2024

I found out that adding logs-max=0 to your ~/.npmrc will disable logging for all your commands 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Information further information is requested Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants