How do I make PostgreSQL log the file path and line number of the errors? (If it's even possible at all.)
Database logging is the wrong end to handle the problem, since the database does not have the required information.
You will have to write your client application so that it logs the information you need whenever it receives a database error.