I need show the referrer for 404 error in the Apache log file.
I found only script in php, it's possible to make through Apache conf?
You can have AccessLogs in Combined Format, which will include Referer and status code:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/access_log combined
in your Apache configuration should do it.