Technical Resources
Educational Resources
Connect with Us
You can now configure JavaScript to send logs directly to the Papertrail HTTPS endpoint. See Log destinations for details.
Logging messages from a client browser, like from Backbone, Angular, Ember, or simple console.log
-style statements? Papertrail has two uniquely flexible ways for aggregating JavaScript log messages. Use the one that works best for your environment.
Logging from a Node.js server rather than a client-side JavaScript app? See Node.js.
Consider this solution regardless of whether you use Heroku. It’s elegant and powerful.
Papertrail integrates with Heroku by automatically collecting all output from a Heroku app and from the Heroku platform. Heroku automatically logs each request.
This is a ready-made log bridge with almost zero effort.
A common way to make supplementary requests as GETs is with an inlined 1×1 image, like this:
<img src="https://your-app-name.herokuapp.com/log?event=somethingHappened" width=1 height=1 style="display: none" />
Heroku’s service is free at low volume, so the setup doesn’t add any cost. The JavaScript-to-syslog bridge can log to an existing standard Papertrail account or to an add-on account set up just for this. See Heroku setup.
The no-op app is a great basic solution, but there are lots of other things you can do, including augment or format the logs and use asynchronous methods to send data back:
For example, Vimeo’s Tattletale.js logging library can send data to Papertrail:
var tattletale = new Tattletale('https://probat-arabica-29.herokuapp.com/log');
tattletale.log('"My name is Ozymandias, king of kings:');
tattletale.log('Look on my works, ye Mighty, and despair!"');
tattletale.log(42);
tattletale.send();
Since Tattletale uses async XHR, a bridge app accepting data from Tattletale requires Cross-origin resource sharing (CORS) to be configured on the app – no longer a no-op, but an easy step in many web frameworks. An example Sinatra app supporting CORS and deployable to Heroku is available here.
The example above uses Heroku’s add-on log integration to send logs to Papertrail, but Heroku isn’t required. You can set up an app and run it anywhere. Since Papertrail accepts syslog (a simple text format for sending logs over the wire), the “bridge” app is a few lines in any common language.
Here’s an example using Papertrail’s Ruby remote_syslog_logger gem to generate the syslog message. Your JavaScript app hits this bridge app and the bridge outputs the log message to Papertrail.
Using Sinatra, implementing a route to process log messages would look something like this:
post '/message'
logger = RemoteSyslogLogger.new('logs.papertrailapp.com', 11111, :local_hostname => 'an-existing-sender', :program => 'js-bridge')
logger.info("Whatever you want, like: #{params[:order_id]} from #{request.remote_ip}")
Using a POST route as shown in this example would require CORS support (see example app).
If the client-side app is associated with an existing server-side app, adding a route to that app to process client log messages (similar to the above example) may be easier than setting up a new app, especially if the server app already logs to Papertrail.
If we can help set up or deploy any of this, or if you’re using another language and would like an example, contact us.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.