2

I have the following function for handling exception.

create or replace function fun_test(a varchar) returns void as
$$
begin

insert into test values(a);

exception when others
then
raise info '%',SQLSTATE;

end;
$$

The above function gives me the output:

OUTPUT:

INFO: 42804

Note: I want to record the same output in the *.log file.

2
  • it very much depends on where you want it - if in postgres log, then just raise warning and change posgtres.conf to log warnings, if you want in other file on the server, you can use COPY, but it won't append to file, etc... please give us details - what exactly you wont, not just *.log Commented Feb 9, 2017 at 9:18
  • I want it in postgres log. Commented Feb 9, 2017 at 9:28

1 Answer 1

1

check docs:

log_min_messages (enum) Controls which message levels are written to the server log. Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level includes all the levels that follow it. The later the level, the fewer messages are sent to the log. The default is WARNING. Note that LOG has a different rank here than in client_min_messages. Only superusers can change this setting.

If you set it to INFO, your raise output will appear in postgres logs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.