Building logrotation into your logging library #programming
.... don't. Just. Don't.
Instead: reopen any open logfiles if you receive a SIGHUP, and let programs like logrotate take care of the rotation.
This is regardless of whether you're a Java library, a Haskell one, or something else.
And never, ever, just don't, rotate the logfile on startup.
If you are running tail -f
on the log file while restarting the
service and get no feedback, you've been hit by this bad behaviour.
Argh.
(Yes, you can use -F
but you shouldn't have to. Just sayin'.)
In case you are using something that logs to stdout and doesn't reopen on SIGHUP, timestampit is your friend - just pipe the output through it, and bob's your uncle.
Add comment
To avoid spam many websites make you fill out a CAPTCHA, or log in via an account at a corporation such as Twitter, Facebook, Google or even Microsoft GitHub.
I have chosen to use a more old school method of spam prevention.
To post a comment here, you need to:
- Configure a newsreaderยน to connect to the server
- Open the newsgroup called
ยน Such as Thunderbird, Pan, slrn, tin or Gnus (part of Emacs).koldfront.dk
on port1119
using nntps (nntp over TLS).lantern.koldfront
and post a follow up to the article.Or, you can fill in this form: