[Enhancement]: Allow adjusting runtime log level without changing NODE_ENV #2439

Closed
opened 2026-04-25 00:07:08 +02:00 by adam · 3 comments
Owner

Originally created by @PhantomPhoton on GitHub (Dec 27, 2024).

Type of Enhancement

Server Backend

Describe the Feature/Enhancement

Add environment variable to control the displayed log level in Logger.js

Why would this be helpful?

I have a very large amount of podcasts and loading the library is very slow. I wanted to enable the benchmark on the database layer to view the queries and their latency, however, the logger will only log INFO level messages unless running as dev.

I tried adjusting the NODE_ENV in the docker image and it crashed due to not being able to load the dev environment.

node:internal/modules/cjs/loader:1228
  throw err;
  ^

Error: Cannot find module './dev'
Require stack:
- /index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/index.js:6:18)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/index.js' ]
}

Node.js v20.18.1

Future Implementation (Screenshot)

Check for process.env.LOG_LEVEL before setting this.logLevel in Logger.js

Audiobookshelf Server Version

v2.17.5

Current Implementation (Screenshot)

As the log lines are currently missing, not sure there's anything I can add here.

Originally created by @PhantomPhoton on GitHub (Dec 27, 2024). ### Type of Enhancement Server Backend ### Describe the Feature/Enhancement Add environment variable to control the displayed log level in [Logger.js](https://github.com/advplyr/audiobookshelf/blob/master/server/Logger.js) ### Why would this be helpful? I have a very large amount of podcasts and loading the library is very slow. I wanted to enable the [benchmark](https://github.com/advplyr/audiobookshelf/blob/master/server/Database.js#L209) on the database layer to view the queries and their latency, however, the logger will only log [INFO](https://github.com/advplyr/audiobookshelf/blob/master/server/Logger.js#L12) level messages unless running as `dev`. I tried adjusting the `NODE_ENV` in the docker image and it crashed due to not being able to load the dev environment. ``` node:internal/modules/cjs/loader:1228 throw err; ^ Error: Cannot find module './dev' Require stack: - /index.js at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15) at Module._load (node:internal/modules/cjs/loader:1051:27) at Module.require (node:internal/modules/cjs/loader:1311:19) at require (node:internal/modules/helpers:179:18) at Object.<anonymous> (/index.js:6:18) at Module._compile (node:internal/modules/cjs/loader:1469:14) at Module._extensions..js (node:internal/modules/cjs/loader:1548:10) at Module.load (node:internal/modules/cjs/loader:1288:32) at Module._load (node:internal/modules/cjs/loader:1104:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/index.js' ] } Node.js v20.18.1 ``` ### Future Implementation (Screenshot) Check for `process.env.LOG_LEVEL` before setting `this.logLevel` in [Logger.js](https://github.com/advplyr/audiobookshelf/blob/master/server/Logger.js) ### Audiobookshelf Server Version v2.17.5 ### Current Implementation (Screenshot) As the log lines are currently missing, not sure there's anything I can add here.
adam added the enhancement label 2026-04-25 00:07:08 +02:00
adam closed this issue 2026-04-25 00:07:08 +02:00
Author
Owner

@nichwall commented on GitHub (Dec 27, 2024):

The log level can be set to WARN, INFO, or DEBUG in the server settings on the Logs page.

You can also manually change the log level in the database in the settings table.

@nichwall commented on GitHub (Dec 27, 2024): The log level can be set to `WARN`, `INFO`, or `DEBUG` in the server settings on the Logs page. You can also manually change the log level in the database in the `settings` table.
Author
Owner

@PhantomPhoton commented on GitHub (Dec 27, 2024):

Oh, thank you very much for the clarification. Apologies for not finding that setting.

@PhantomPhoton commented on GitHub (Dec 27, 2024): Oh, thank you very much for the clarification. Apologies for not finding that setting.
Author
Owner

@nichwall commented on GitHub (Dec 27, 2024):

No worries, there are a few things like this that would be good to expose as an environment variable, it just hasn't been exposed since configuration should (currently) be done through the web UI.

@nichwall commented on GitHub (Dec 27, 2024): No worries, there are a few things like this that would be good to expose as an environment variable, it just hasn't been exposed since configuration should (currently) be done through the web UI.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2439