Ensure you have "log_connections" and "log_disconnections" set to "on" in your postgresql.conf. This will add the connection info to your postgres logs. Keep in mind if you have a very high connection rate, this can cause a very noticeable increase in your log size. If you did not have these turned on before, there's nothing I'm aware of within the database itself that tracks connections in the manner you're looking for. pg_stat_activity only shows what is happening right at that moment when you query it.