Not specifically an answer asked for but maybe a better way, depending on your scenario, would be to to not log to stdout/stderr at all. Just pipe the logs to cat in a JSON format. This would remove the need to differentiate the streams as the json could have the data needed in it to distinguish them. eg something along the lines of the following. This can then be ingested much more easily into something like graylog
GlobalLog "| cat - " gelf ErrorLog "| cat - " LogFormat "{ \"apache_log\": \"ACCESS\", \"app_name\": \"apache\", \"Connection\": \"%{X-Forwarded-Proto}i:%{X-Forwarded-Port}i \", \"X-Forwarded-For\": \"%{X-Forwarded-For}i\", \"version\": \"1.1\", \"vhost\": \"%V\", \"short_message\": \"%r\", \"timestamp\": %{%s}t, \"level\": 6, \"user_agent\": \"%{User-Agent}i\", \"source_ip\": \"%a\", \"duration_usec\": %D, \"duration_sec\": %T, \"request_size_byte\": %O, \"http_status\": %s, \"http_request_path\": \"%U\", \"http_request\": \"%U%q\", \"http_method\": \"%m\", \"http_referer\": \"%{Referer}i\", \"X-Powered-By\": \"%{X-Powered-By}i\" }" gelf ErrorLogFormat "{ \"app_name\": \"apache\", \"apache_log\": \"ERROR\", \"time\":\"%{%Y-%m-%d}tT%{%T}t.%{msec_frac}tZ\", \"function\" : \"[%-m:%l]\" , \"process\" : \" [pid %P:tid %T] \" , \"message\" : \"%M\" ,\ \"referer\"\ : \" %{Referer}i \" }"
There is also a gelf logging module, so you can stream direct from apache to a graylog type server as well if you wish