我有一個小型代碼寫入一個小的代碼發送消息到系統日誌使用C Api's,當無法連接到postgres數據庫。如何避免來自系統日誌廣播消息打印在控制檯上
int main (int argc, char **argv)
{
PGconn *psql;
PGresult *res;
int flag = 0;
openlog ("postgres", LOG_NDELAY, LOG_SYSLOG);
psql = PQconnectdb("hostaddr = '127.0.0.0' port = '5432' dbname = 'RtpDb' user = 'rtp_user_99' password = 'rtp_user' connect_timeout = '10'");
if (PQstatus(psql) != CONNECTION_OK)
{
//Send an event to syslog for DB Connection Failure
syslog (LOG_EMERG, "%s", PQerrorMessage(psql))
}
closelog();
PQclear(res);
PQfinish(psql);
}
當有一個連接失敗Postgres數據庫裏的信息被打印輸出上,即使選項LOG_CONS不openlog啓用控制檯。
Broadcast message from [email protected] (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 [email protected] 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?
請問我可以幫助我如何避免在控制檯上打印的信息。
相關:。http://serverfault.com/a/392333/143982 – alk
那麼,竟敢顯示你的syslog-daemon的配置? – alk