How to get logs from the Node agent

  • Updated


 In rare scenarios, bad instrumentation causes a web server process to crash or a specific page to error out. If you ever encounter a crash or error caused by Contrast, please report the error via the Submit a Request link at the bottom of this page.

If possible, follow the steps below to gather agent logs; this additional information is vital to reproducing and fixing these types of bugs.


You can ask Contrast to log verbose information by doing one of the following.

--agent.logger.path /path/to/trace_contrast_agent.log 
--agent.logger.level TRACE

Some examples of usage:

If you've added contrast to the scripts section of your application's package.json file:

npm run contrast -- --agent.logger.path ./contrast_trace.log --agent.logger.level TRACE

If you're running the node agent directly with node -r @contrast/agent, we'll want to follow this format:

node -r @contrast/agent app-main.js [agent arguments] -- [app arguments]

node -r @contrast/agent app-main.js --agent.logger.path ./contrast_trace.log --agent.logger.level TRACE -- [app arguments]
  • Contrast_security.yaml file: (more information can be found here in our docs)
   path: /path/to/trace_contrast_agent.log
   level: TRACE
  • Environment Variables:


If your application is running in an SaaS/CaaS environment where the logs are not easily accessible, logging can be sent to STDOUT instead by one of the following methods:

For the Node.js agent you must manually configure DEBUG. INFO-level statements aren't logged to the console unless the environment variable DEBUG is set to include the Contrast namespace: DEBUG=contrast:*. This could be useful in environments where you don't have access to the file system (like Docker or ECS).

--agent.logger.path /dev/stdout
--agent.logger.level TRACE
  • Contrast_security.yaml file: (more information can be found here in our docs)
path: /dev/stdout
level: TRACE
  • Environment Variables:


 These options will put Contrast into debug mode and log all output to the log file specified as the system property value. It will also prevent the log from rolling over into multiple files. The log file will start with some messages that look similar to this:


These verbose logs will allow our support team to diagnose any issues you may encounter. To contact the Contrast Support Team, please submit a ticket to our online support portal. 


Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request