0

So I am using lager for logging and trying to achieve a particular scenario here

Currently we have single lager sink for our erlang project which has multiple apps and now we want per-app lager sink, but we don't want to break the logs into multiple files also. Is this achievable? Can two lager sinks log into same file for example (same debug.log for all app sinks) and if yes are there any limitations to it?

SilverBlaZe
  • 85
  • 1
  • 5

1 Answers1

0

Lager author here. You likely cannot point multiple sinks at the same file, because the sink opens the file in raw mode, so you can't write to it from a different process. Trying to do so will probably either fail or randomly interleave writes from both sinks (or corrupt the file).

However, I didn't write the multiple sink stuff, and I've never really used it. Why do you want to do this, maybe there's a simpler way to achieve what you want?

  • Hi! Thanks for the answer @andrew. The main target here is that adding multiple sinks for respective apps would ensure that logging remains independent for these apps. Some issues we faced in production was that because we had a single lager sink, some apps which weren't logging that much also were affected due to lager going to sync mode and also some logs lost due to event flushing from msg queue. – SilverBlaZe May 12 '20 at 20:09