Timber fully embraces, and encourages, structured data in your logs. So much so that we designed a system to transparently attach metadata without changing the original log line. This allows you to attach rich data to your logs without sacrificing readability. To make this easy and automatic, we’ve designed libraries that handle this for you. The end result is higher quality logs and faster problem solving.

How it works

Take these familiar log lines:

Started Get "/"
Processing by WelcomeController#index as html
Rendered welcome/index.html.erb (0.2ms)
Completed 200 OK in 2.46ms

With the Timber libraries, these become:

Started Get "/" @metadata { "event": { "http_server_request": {...}, "context": {...} } }
Processing by WelcomeController#index as html @metadata { "event": { "controller_call": {...}, "context": {...} } }
Rendered welcome/index.html.erb (0.2ms) @metadata { "event": { "template_render": {...}, "context": {...} } }
Completed 200 OK in 2.46ms  @metadata { "event": { "http_server_response": {...}, "context": {...} } }

Notice each line is delimited by a @metadata callout. This separates the original log message from the metadata. The metadata is simply a JSON document. If you haven’t, check out our log line JSON schema doc.

Also, notice each line is assigned an event type: http_server_request, controller_call, template_render, and http_server_response (respectively). And, all of the lines share context. An example of what context might look like:

{
  "context": {
    "http": {"method": "GET", "path": "/", "remote_addr": "123.23.21.213", "request_id": "abcd1234"},
    "user": {"id": "1", "name": "Ben Johnson", "email": "[email protected]"},
    "server": {"hostname": "server.hostname.com", "pid": "1234322"}
  }
}

Finally, to define each of these:

  1. event - Is data directly related to the respective event.
  2. context - Represents the current state of the environment when the log line was written. Think of it like join data for your logs.

What can I do with this data?

So many great things! Checkout these articles:

  1. Attribute searching
  2. Graphing
  3. Alerting
  4. Integrations

How do I get this data?

Simply pick your language and follow the installation instructions:

Full list of events and contexts

These are described within the section that provides the context or event. See:

Questions? Need help?

Chat with us, just click the talk button in the bottom right of this page.

Chat with us

Start a trial - 15 days free

Log better and solve problems faster, today. Less than 1 minutes to install.

Start a trial