Show application name instead of process in warning (PostgreSQL)
Just include %p and %a in your log_line_prefix and set log_disconnections = on.

Then you get the application name and process ID logged whenever a session disconnects. That will enable you to find in the log which application name belongs to which session. This will work unless sessions are in the habit of changing their application_name.

For active connections, just examine pg_stat_activity.