diff --git a/README.md b/README.md index c97287b..59ec657 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1179 TILs and counting..._ +_1180 TILs and counting..._ --- @@ -595,6 +595,7 @@ _1179 TILs and counting..._ - [Get The Size Of An Index](postgres/get-the-size-of-an-index.md) - [Getting A Slice Of An Array](postgres/getting-a-slice-of-an-array.md) - [Group By The Result Of A Function Call](postgres/group-by-the-result-of-a-function-call.md) +- [Include All Queries In The Log File](postgres/include-all-queries-in-the-log-file.md) - [Insert A Bunch Of Records With Generate Series](postgres/insert-a-bunch-of-records-with-generate-series.md) - [Insert Just The Defaults](postgres/insert-just-the-defaults.md) - [Install Postgres With uuid-ossp Using asdf](postgres/install-postgres-with-uuid-ossp-using-asdf.md) diff --git a/postgres/include-all-queries-in-the-log-file.md b/postgres/include-all-queries-in-the-log-file.md new file mode 100644 index 0000000..8330a5e --- /dev/null +++ b/postgres/include-all-queries-in-the-log-file.md @@ -0,0 +1,22 @@ +# Include All Queries In The Log File + +The default log-level (`log_statement` setting) for a PostgreSQL server is +`none`. Other valid log-levels for [that setting are `ddl`, `mod`, and +`all`](https://www.postgresql.org/docs/13/runtime-config-logging.html). + +If you want to see all the queries hitting a database, you'll want to set it to +`all`. This can be set as a server-wide setting or it can be set on a +per-session basis. + +Because `all` is so noisy, I like to use it on a per-session basis when I'm in +a situation where I know I'd like to see all queries. + +```sql +> set log_statement = 'all'; +``` + +After running that statement in my `psql` session, I can tail the log file to +keep an eye on queries hitting the database. + +Be sure that [logging is enabled via the +`logging_collector`](enable-logging-of-database-activity.md) as well.