A local logging solution.
- Timber is a project that consumes simple text logs by piping the output of a local project.
- It allows for filtering using Elasticsearch querying, and can help you find logs by application, source in the app (assets, web, etc), and by time.
docker pull docker.pkg.github.com/jules2689/timber/timber:latest
docker run -p 6778:3000 --name timber -v es-data:/var/lib/elasticsearch -t docker.pkg.github.com/jules2689/timber:latest
- Wait for it to launch, including Elasticsearch, then run this test command:
curl -X POST "http://localhost:6778/logs?log_type=url&application=test&log=test&source=test"
. This should result in a test log in the application. - Launch https://localhost:6778 to see the log come in
Note: The -v
will mount in the es-data
volume mount on your local machine. This will allow you to save Elasticsearch indices and data between runs of Docker.
Timber can support logs from overmind
applications by using the overmind echo
feature. To send logs, create a bash file like this one:
#!/usr/bin/env sh
application=$1
while read var; do
curl -H "Content-Type: application/text" -X POST -d "$var" "http://localhost:6778/logs?log_type=overmind&application=$application" >/dev/null 2>&1
done
Then call overmind echo | /path/to/file APP_NAME
, replacing APP_NAME
with the name of your application.
Timber can support logs in JSON format too. As an example, this bash file should send logs much like the Overmind example:
#!/usr/bin/env sh
application=$1
while read var; do
curl -H "Content-Type: application/json" -X POST -d '{ "log_type" : "json", "application" : "$application", "log": {...} }' "http://localhost:6778/logs" >/dev/null 2>&1
done
This likely isn't how you'd call the JSON functionality, you'd likely call it from within your app where you have structured access.
The key part is the json data is { "log_type" : "json", "application" : "$application", "log": {...} }
, and the endpoint is http://localhost:6778/logs
#!/usr/bin/env sh
application=$1
while read var; do
curl -X POST "http://localhost:6778/logs?log_type=url&application=$application&log=my_special_url_encoded_log" >/dev/null 2>&1
done