Logging

Started by Andrew Bartleyalmost 8 years ago7 messagesgeneral
Jump to latest
#1Andrew Bartley
ambartley@gmail.com

Hi all,

Can someone please tell me how to log the values being inserted in this
example..

2018-06-12 22:31:49 UTC-5b2049d4.434ac-STATEMENT: insert into
"api_consumers" ("consumer_id", "create_datetime") values ($1, $2).

I have tried many different logging options and combinations.

Thanks

Andrew Bartley

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Andrew Bartley (#1)
Re: Logging

Andrew Bartley wrote:

Can someone please tell me how to log the values being inserted in this example..

2018-06-12 22:31:49 UTC-5b2049d4.434ac-STATEMENT: insert into "api_consumers" ("consumer_id", "create_datetime") values ($1, $2).

I have tried many different logging options and combinations.

That should automatically be logged as a DETAIL message.

log_min_duration_statement = 0
log_min_error_statement = log or better
log_min_messages = log or better

That should do the trick.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

#3Andrew Bartley
ambartley@gmail.com
In reply to: Laurenz Albe (#2)
Re: Logging

On Wed, 13 Jun 2018 at 12:43 Laurenz Albe <laurenz.albe@cybertec.at> wrote:

Andrew Bartley wrote:

Can someone please tell me how to log the values being inserted in this

example..

2018-06-12 22:31:49 UTC-5b2049d4.434ac-STATEMENT: insert into

"api_consumers" ("consumer_id", "create_datetime") values ($1, $2).

I have tried many different logging options and combinations.

That should automatically be logged as a DETAIL message.

log_min_duration_statement = 0
log_min_error_statement = log or better
log_min_messages = log or better

That should do the trick.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

Thanks for the reply Laurenz,

Current settings

"PostgreSQL 9.6.7, compiled by Visual C++ build 1800, 64-bit"
Azure managed instance

log_min_duration_statement -1
log_min_error_statement DEBUG2
log_min_messages DEBUG2
log_statement ALL
log_error_verbosity VERBOSE

Still no joy.

Thanks Andrew

#4David G. Johnston
david.g.johnston@gmail.com
In reply to: Andrew Bartley (#3)
Re: Logging

On Tuesday, June 12, 2018, Andrew Bartley <ambartley@gmail.com> wrote:

On Wed, 13 Jun 2018 at 12:43 Laurenz Albe <laurenz.albe@cybertec.at>
wrote:

log_min_duration_statement = 0

[...]

log_min_duration_statement -1

You've disabled statement logging altogether. The zero value you were
directed to use is what causes everything to be logged.

David J.

#5Andrew Bartley
ambartley@gmail.com
In reply to: David G. Johnston (#4)
Re: Logging

Ok, thanks. will try

On Wed, 13 Jun 2018 at 13:25 David G. Johnston <david.g.johnston@gmail.com>
wrote:

Show quoted text

On Tuesday, June 12, 2018, Andrew Bartley <ambartley@gmail.com> wrote:

On Wed, 13 Jun 2018 at 12:43 Laurenz Albe <laurenz.albe@cybertec.at>
wrote:

log_min_duration_statement = 0

[...]

log_min_duration_statement -1

You've disabled statement logging altogether. The zero value you were
directed to use is what causes everything to be logged.

David J.

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: David G. Johnston (#4)
Re: Logging

On 06/12/2018 08:25 PM, David G. Johnston wrote:

On Tuesday, June 12, 2018, Andrew Bartley <ambartley@gmail.com
<mailto:ambartley@gmail.com>> wrote:

On Wed, 13 Jun 2018 at 12:43 Laurenz Albe <laurenz.albe@cybertec.at
<mailto:laurenz.albe@cybertec.at>> wrote:

log_min_duration_statement = 0

[...]

log_min_duration_statement -1

You've disabled statement logging altogether.  The zero value you were
directed to use is what causes everything to be logged.

Actually no:

https://www.postgresql.org/docs/10/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHEN

log_min_duration_statement (integer)

"... Setting this to zero prints all statement durations. Minus-one (the
default) disables logging statement durations. ..."

"

So -1 only affects logging statements relative to duration.

If you have log_statements set then you will still get statements logged
if you have log_min_duration_statement = -1 :

Note

When using this option together with log_statement, the text of
statements that are logged because of log_statement will not be repeated
in the duration log message.
"

This is how I have my logging setup, log_min_duration_statement = -1
and log_statements = 'mod' and I see statements in the logs.

David J.

--
Adrian Klaver
adrian.klaver@aklaver.com

#7Andrew Bartley
ambartley@gmail.com
In reply to: Adrian Klaver (#6)
Re: Logging

Thanks All,

It seems that the related DETAIL message appears if the query is
successful. On error the DETAIL log line is missing... This makes
debugging difficult, considering the insert is coming from Dreamfactory via
a rest POST.

I am finding it very difficult navigating my way through the brave new
world of SAS and Blackbox type applications.... Maybe 32 years as a
database programmer is just too long.

Thanks

Andrew

On Wed, 13 Jun 2018 at 14:12 Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

Show quoted text

On 06/12/2018 08:25 PM, David G. Johnston wrote:

On Tuesday, June 12, 2018, Andrew Bartley <ambartley@gmail.com
<mailto:ambartley@gmail.com>> wrote:

On Wed, 13 Jun 2018 at 12:43 Laurenz Albe <laurenz.albe@cybertec.at
<mailto:laurenz.albe@cybertec.at>> wrote:

log_min_duration_statement = 0

[...]

log_min_duration_statement -1

You've disabled statement logging altogether. The zero value you were
directed to use is what causes everything to be logged.

Actually no:

https://www.postgresql.org/docs/10/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHEN

log_min_duration_statement (integer)

"... Setting this to zero prints all statement durations. Minus-one (the
default) disables logging statement durations. ..."

"

So -1 only affects logging statements relative to duration.

If you have log_statements set then you will still get statements logged
if you have log_min_duration_statement = -1 :

Note

When using this option together with log_statement, the text of
statements that are logged because of log_statement will not be repeated
in the duration log message.
"

This is how I have my logging setup, log_min_duration_statement = -1
and log_statements = 'mod' and I see statements in the logs.

David J.

--
Adrian Klaver
adrian.klaver@aklaver.com