Logging

AppHarbor supports advanced realtime logging with multiple integration points. Logs are delivered as streams of log events from the infrastructure components the comprises the AppHarbor platform along with output directly from your applications. Your application logs can easily be integrated with add-on providers such as Logentries and you may add your own log endpoints if you prefer to process logs yourself. Additionally AppHarbor provides both a web and a CLI interface for accessing your log data in real time.

Sources

The logging module collates log messages from multiple sources including almost every AppHarbor infrastructure component and your apps. The log sources currently includes:

  • API: Most API events are logged so you'll be able to see when you or somebody working on the application make a change through the API or appharbor.com.
  • Load balancer: Detailed request logs from nginx enables you to see the IP, browser, request URLs and response codes as requests are served.
  • Build: The build logs displayed when you click on a build also report to the logging module.
  • Deploy: Detailed information about deployments, pre warming etc.
  • Router: Notifications about routing configuration changes.
  • Tracing: Use .NET tracing to log trace messages from anywhere in your application, including web workers. More details can be found in this article.
  • Background workers: All standard output and standard error is streamed directly to the logging module along with detailed information about the operation of the process manager that runs with your background workers. You can log simply by writing to the console and all your exceptions will automatically be logged.

Integration points

AppHarbor provides multiple integration points with the logging module. Providing access to your logs in realtime is one thing, but AppHarbor will only store the last 1500 log messages for your application. Storing, searching, viewing and indexing logs can be fairly complex and luckily many services already exists that addresses this need. There are three ways to integrate with external services:

Addons

A lot of customers use the Logentries add-on for logging. Logentries provides a completely automated and convenient way for sending AppHarbor logs to them. When you add the Logentries add-on your application will automatically be configured to send logs to Logentries, and Logentries will be configured to display log messages in AppHarbor's format. A token is still returned and can be used with your application so you can continue to use the logging you already have in place.

Log drains

With log drains you can send log messages to any syslog (TCP), HTTP and HTTPS services. This allows you to integrate with other logging services, such as Loggly and Splunk, or with your own syslog server or HTTP-capable service that is capable of handling AppHarbor's log format. Each log message will contain a unique, secret token that you can use to verify the authenticity of the web request.

Drains can be configured using the web or command line interface, as well as using the drain API.

Log messages delivered over TCP are formatted according to RFC 5424. You can add these drains by using a syslog URL such as syslog://example.com.

You can read more about HTTP and HTTPS log drains in the logplex drain documentation

Log session API

A log session API endpoint is available for getting a URL for a log session. This is what the CLI and log web interface uses to display logs, and you can use the log session endpoint to create your own interfaces. Log sessions are short-lived and will expire after a minute. You'll need to keep the connection open to continue streaming log messages, so consider using log drains for more stable integrations.

The logging module also has integration points for add-on providers to send log messages back to AppHarbor. We'll work with our add-on providers to make sure more of them support this capability. If you're an add-on provider make sure to reach out to hear more about this.

Logplex

If you've ever used Heroku you'll find most of these feature very familiar. That's no coincidence - the backend is based on Heroku's awesome distributed syslog router, Logplex. If you need more information about the logging module you may also be able to find it in Heroku's logging documentation.