what would be the "best" way to log all error 500 (all status 50x responses in fact) into a separate logfile ?
One way could be a piped log, but depending of the format the user has configured the output can be very different.
use piped log and tell your users to put the status in a certain location
write a custom module that implements the log-transaction hook, and do whatever you want for status==500
I think of something like a (transparent) filter in the output chain.
having your custom module implement the log-transaction hook would be more straightforward