[erlang-questions] Logs and stdout [OFFTOPIC]

Loïc Hoguin essen@REDACTED
Fri Nov 25 12:00:33 CET 2016

There are no better solutions, only pros and cons.

The good thing about lager is that all solutions are available and can 
be stacked, so you can customize where your logs go as you will.

You can for example send them both on disk and to journald directly with 
https://github.com/travelping/lager_journald_backend - this one allows 
setting extra fields, I am not sure you can do that when redirecting 
stdout. Then you get the best of both worlds.

When writing logs to files, there shouldn't be an assumption that disks 
are involved, you could very well write to a pseudo partition mounted as 
a file system, to a remote partition mounted locally, to a memory file 

Stdout is not better supported across platforms. The Windows task 
manager and services will not log stdout by default, for example. On 
Unix, it largely depends on how the node is started. If your node is an 
always-on server managed by systemd/init, then sure, but if you make an 
interactive application this output will be dropped.

Stdout also doesn't sound more flexible, see the comment about extra 
fields in journald for example. Different log storages provide different 
extensions that you may wish to take advantage of.

The 12 factor app document reads very much like a "works for us". There 
are many more scenarios than the ones it covers.

Saving to log files on disk works for my customers as far as I know. In 
their case it's fine to lose some logs because of disk corruption, as 
the logs are used for debugging purposes only. Your mileage may vary.

On 11/25/2016 11:34 AM, Alexander Petrovsky wrote:
> Hello!
> On my work I have to write in golang, so, with my erlang background I
> used to write logs into file on disk via lager, for me it's very
> conveniently and I see some pros:
> - We can route logs by application and control them are more flexible;
> - We can control when and what and how to sink data to disk, so, we have
> some guarantees.
> For me, stdout/stderr cons is stdX it's always pipe, so, when log reader
> got stuck, all my app is got stuck too.
> The my very (for me) strange golang programmers colleagues, says - no,
> it's wrong and bad, we all must write logs to stdout, here there is cons
> for write log files:
> - Disk can corrupt! Write to stdout, catch up by journald and route to
> some place. So, there is no disk point of failure any more, you app now
> network depends only;
> - Stdout more flexible, it's more cross platform;
> - Hey, boy, did you know about 12 app factor (*oh my god*)?
> Sorry for full of pain and holly war topic, but for me is very
> interesting what's erlang community think about it?
> --
> Петровский Александр / Alexander Petrovsky,
> Skype: askjuise
> Phone: +7 914 8 820 815
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Loïc Hoguin

More information about the erlang-questions mailing list