Skip to content

Manually log errors in New Relic

For debugging purposes, custom errors can be manually logged in PHP code using the trigger_error() function, along with a minimum error level (second argument) of E_USER_WARNING. The default is E_USER_NOTICE.

On VIP Platform WordPress environments, custom errors can be logged in New Relic using 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().

Ingest API

NewRelic’s Ingest API can be used to report custom telemetry data including custom events using an HTTP POST request method. This method provides a response status code that can be used to track the reliability of the ingested data. To obtain an Ingest API license key, submit a request to VIP Support.

Note

The availability of the Ingest API is intended only for troubleshooting complex issues. Do not use the Ingest API for constant or large-scale data transfer (e.g. sending large amounts of data that cover general error types or a large portion of customer transactions). If New Relic data ingestion by an application increases beyond an amount that WPVIP considers acceptable, access will be blocked.

Last updated: September 12, 2024

Relevant to

  • WordPress