- Get your destination from your account at https://papertrailapp.com/account/destinations
- Install as a plugin or load it up in mu-plugins
- Define your constant in wp-config.php
WP_PAPERTRAIL_DESTINATION
You can use this Greasemonkey script to make the JSON logging look much better (and works with Tampermonkey with a small tweak, see comments).
https://gist.github.com/troy/55442ad0d2502f9ac0a7
// Log data
$success = WP_Papertrail_API::log( $some_string_array_or_object, 'Some optional identifier' );
if ( ! is_wp_error( $success ) ) {
// Successfully logged to Papertrail
}
You will need to define the destination to log to in wp-config.php (see https://papertrailapp.com/account/destinations)
define( 'WP_PAPERTRAIL_DESTINATION', 'logs1.papertrailapp.com:12345' );
You can log PHP errors to Papertrail too, using this easy to set constant:
define( 'WP_PAPERTRAIL_ERROR_HANDLER', true );
Please be aware, some codebases produce a large amount of notices, warnings, or other messages even when they aren't displayed on the screen. Be careful with this handler enabled and watch your Papertrail plan as you might approach your limit quickly.
You can specify the error reporting levels you would like to log to Papertrail by defining the log level constant in wp-config.php
:
// log all errors except deprecated errors
define( 'WP_PAPERTRAIL_LOG_LEVEL', E_ALL & ~E_DEPRECATED );
See the PHP documentation for more information on this configuration option.
Props have to go to Troy Davis (@troy on GitHub, @troyd on Twitter) who came up with the PHP interface to communicate with the Papertrail API.
See the original gist code here: https://gist.github.com/troy/2220679
I also referenced the Stream to Papertrail plugin (https://github.com/Japh/stream-to-papertrail) initially.