Home > Back-end >  How to send logs to papertrail heroku add-on from a job not running on heroku?
How to send logs to papertrail heroku add-on from a job not running on heroku?

Time:03-22

I have an application running on Heroku using the papertrail add-on. Everything works perfectly and logs from that app are shown in there. My problem comes when I want to log to the same papertrail account from jobs running in other servers like AWS. In particular, I'm trying to setup a docker container for jobs that are only run in certain occasions (and for some technical limitations they cannot be run in heroku).

I have checking how to setup the unix loggers to automatically send logs to papertrail. My problem is that I do not have a papertrail dns or a port. Heroku only gives a papertrail token.

Any idea how to send logs to papertrail using my add-on credentials from a different unix server?

CodePudding user response:

You can use logspout which can route all container logs (from the host) to a different location, for example to papertrail.

You can find a docker run example of the website, here below is a docker-compose example which is quite convenient when you run multiple containers and want to gather all logs together.

The destination logs2.papertrailapp.com:55555 is provided by Papertrail in Settings->Log Destinations

logspout:
  image: gliderlabs/logspout:latest
  container_name: logspout
  restart: always
  volumes:
    - "/var/run/docker.sock:/var/run/docker.sock:ro"
  command: syslog tls://logs2.papertrailapp.com:55555
  ports:
    - 8082:80
  networks:
    - my_network
  • Related