Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to prevent Postgresql from logging ERRORs caused by attempted insertions where a UNIQUE KEY constraint is violated?

I could change the server_log_min directive, but this would disable all ERROR messages and not just those for UNIQUE KEY constraint.

share|improve this question
up vote 0 down vote accepted

No. No such way exists. Short of piping logs via | grep -v ... | filter.

share|improve this answer
i guess i'll have to do some sort of log file post-processing... – bugmenot77 Oct 1 '09 at 20:39
Actually. Anyone know if there's a way to specify piping via sed script through the conf file? – bugmenot77 Jan 13 '10 at 23:50

There's no way to do this just by adjusting the logging mechanism on the server. You could do it by hacking the source code if you absolutely had to; the relevant code is in src/backend/access/nbtree/nbtinsert.c and looks like this, around line 300:

        errmsg("duplicate key value violates unique constraint \"%s\"",

You could change the log level there from ERROR to LOG or NOTICE.

share|improve this answer
thanks. i thought of hacking source code but it would end up being another maintenance nightmare! :) – bugmenot77 Oct 1 '09 at 20:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.