Day 51: Logging cleanup and two new strace puzzles

Consolidated server logging

My server was logging in three separate places, which made debugging confusing:

  • Rails wrote to production.log
  • The Go proxy used Docker Compose's default logging
  • The Firecracker manager service logged to journald

To fix this, I set RAILS_LOG_TO_STDOUT=1 and configured Docker Compose to send logs to journald:

  rails:
    environment:
      - RAILS_LOG_TO_STDOUT=1 
    logging:
      driver: "journald"
      options:
        tag: "rails"
    build: 
        dockerfile: docker/rails/Dockerfile
        context: .

Once everything was in journald, querying journalctl for those services was unwieldy. I added a small helper function to my .bashrc to make it easier.

function logs {
    journalctl -b SYSLOG_IDENTIFIER=$1 | less +G
}

Strace starter puzzles

I also wrote two quick puzzles for practicing strace. The first, "the case of the misconfigured logger," presents a program called run-me that writes its logs to /dev/null instead of a file — the goal is to use strace to see what it's writing.

There's a program in your home directory called run-me. For some reason, it's been misconfigured so that it's writing its logs to /dev/null instead of to a file. But you need to know what it's writing!

Use strace to find out what it's writing.

The second, "the case of the mystery log file," asks you to find a log file name that's absent from all documentation.

There's a program in your home directory called run-me. It's logging its output to a log file, but you can't find the name of the log file ANYWHERE in its documentation!

Use strace to find out the name of the log file.

Both are rough drafts — each took about five minutes to write. They need more work, but that's likely to happen after RC ends.