Skip to content

Manually log errors in New Relic

For debugging purposes, custom errors can logged in New Relic by either manually adding them to the Runtime Logs via PHP or logged only to New Relic by using the function newrelic_notice_error().

Errors can be triggered with code similar to this example:

if ( extension_loaded( 'newrelic' ) ) {
    newrelic_notice_error( 'My custom error message' );
}

For more information, refer to New Relic’s function documentation.

Note

If there are multiple calls to newrelic_notice_error() in a single transaction, the PHP agent will retain the exception from the last call only.

Alternatively, the newrelic_record_custom_event() function can be used to keep track of data and log events without considering it to be an error.

For more information, refer to New Relic’s function documentation for newrelic_record_custom_event().

Last updated: July 15, 2025

Relevant to

  • WordPress