How to avoid Broadcast messages from syslog printed on the console
After the hint provided by @alk, i did some more research and found how to avoid the messages being printed on the console.
Broadcast message from systemd-journald@blr09 (Tue 2017-01-03 05:24:46 EST):postgres[40933]: could not connect to server: Network is unreachable Is the server running on host "127.0.0.0" and accepting TCP/IP connections on port 5432?Message from syslogd@blr09 at Jan 3 05:24:46 ... postgres:could not connect to server: Network is unreachable#012#011Is the server running on host "127.0.0.0" and accepting#012#011TCP/IP connections on port 5432?
The above message have two parts:
Broadcast message from systemd-journald => These messages will be printed on the console by journalctl when emergency messages are sent. To disable these messages we need to disable ForwardToWall ie., ForwardToWall=no in /etc/systemd/journald.conf
Message from syslogd => These messages are printed by rsyslog because of the below configuration line in /etc/rsyslog.conf
*.emerg :omusrmsg:*
This selector-action states "Emergency messages often go to all users currently online to notify them that something strange is happening with the system. To specify this wall(1)-feature use an ":omusrmsg:*"." Comment this line out.
After performing the above operations the messages were not printed on the console. As these operations were not allowed due to security threats, I am raising the events with Alert priority.
syslog ( LOG_ALERT, "%s", PQerrorMessage(psql) );
Thanks to @alk.