Add log message for no config file found
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently !config
results in a message ‘Module not enabled in configuration; not starting.’
if (!config || !config.agent_enabled) {
logger.info('Module not enabled in configuration; not starting.')
https://github.com/newrelic/node-newrelic/blob/main/index.js#L79
This can be misleading and makes troubleshooting more difficult when it could be two very different issues.
Feature Description
Add a log message similar to what the Ruby agent has:
NewRelic::Agent.logger.warn(
"No configuration file found. Working directory = #{Dir.pwd}",
"Looked in these locations (based on #{based_on}): #{candidate_paths.join(", ")}"
It may be worthwhile to include next steps as the missing ‘app_name’ log message does:
For example:
New Relic requires a newrelic.js file in the root directory of your app or set environment variable NEW_RELIC_NO_CONFIG_FILE=true
But it may be difficult to include all possible cases, for example if using ‘NEW_RELIC_HOME’ rather than having ‘newrelic.js’ in the root directory.
Describe Alternatives
Current troubleshooting strategy when logs show ‘Module not enabled in configuration; not starting.’ :
-
Check newrelic.js for
agent_enabled: false
-
Confirm no New Relic environment variables are present that could be disabling the agent with the methods here: https://discuss.newrelic.com/t/node-js-troubleshooting-framework-configuration/119977#post_1:~:text=If you used New Relic environment,vars are correctly loading in time
-
Test enabling the agent in your start up script which will override any other configuration, for example:
NEW_RELIC_ENABLED=true node server.js
-
Use the environment variable ‘NEW_RELIC_NO_CONFIG_FILE’ to skip looking for the agent configuration file and use environment variables to set configuration: https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration#no_file
-
Set path to directory containing newrelic.js the environment variable ‘NEW_RELIC_HOME’:
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
@carlo-808 I already had logging disabled via the config file.
Turned out I had to remove
process.env.NEW_RELIC_NO_CONFIG_FILE = 'true';
from my Jest setup file. Now no logs are shown anymore while running automated tests.Is there a way to disable this log message (e.g. while running automated tests)?