Passenger and stdout/stderr

Hello,

when I was debugging a VmWare bug on production system, I realized that
Foreman in Passenger setup likely throw away all content that goes to
stdout/stderr.

Does anyone know a trick how to redirect $stdout and $stderr into Rails
logging facility (as debug messages)? There must be a trick for that. We
should do this in an initializer so messages won't get lost.

For example for/vmware library rbvmomi is capable of doing some debug
output, but it won't work with Passenger as stderr is hidden.

··· -- Later, Lukas #lzap Zapletal

> Does anyone know a trick how to redirect $stdout and $stderr into Rails
> logging facility (as debug messages)? There must be a trick for that. We
> should do this in an initializer so messages won't get lost.

Ok this does the trick:

$stderr.reopen logger.instance_variable_get(:@logdev).dev

Breaks encapsulation and not the safest method. The alternative is to
create wrapper IO class:

Now part of: https://github.com/theforeman/foreman/pull/2304

··· -- Later, Lukas #lzap Zapletal