PostgreSQL: Where to find the Log-file

I freshly installed PostgreSQL with an user-defined data-directory. PostgreSQL is running fine, but I can’t find the postgresql*.log(s), which I used to find in /var/log/postgresql on my former system. In ksystemlog I’ve seen an error, that I forced, but I’m wondering, if there is no longer the postgresql*.log.
Thank you!
My postgresql.conf can be found here.

Hi @MaMicha,

I might be wrong about this, I haven’t had the need to check apache/mysql/postgresql/mariadb logs in a very long time. I think it’s now accesible with journalctl.

You’d have to look further into it to be sure, but I thibk that’s how it’s viewed. At least with systemd. I think.

Thank you!

Right, this is what I found using ksystemlog (KDE-Desktop). Is there any easy way to filter last postgres issues like (UNIT = postgres IS NOT CORRECT!!):
# journalctl --since "20 min ago" *UNIT=postgres*

Unfortunately, I have absolutely no idea what it’d be. But you’ve got the right idea there!

Some progress:
journalctl -u postgresql --since "600 min ago"
delivers only postgres messages for the defined time period. How to add a filter, so that only errors are listed?

According to this post on Serverfault the syntax is:

journalctl -u service-name -f

Where -f is follow. So try,

journalctl -u <replace_with_postgres_service_name> -f

According to this page:

By Priority

One filter that system administrators often are interested in is the message priority. While it is often useful to log information at a very verbose level, when actually digesting the available information, low priority logs can be distracting and confusing.

You can use journalctl to display only messages of a specified priority or above by using the -p option. This allows you to filter out lower priority messages.

For instance, to show only entries logged at the error level or above, you can type:

journalctl -p err -b

This will show you all messages marked as error, critical, alert, or emergency. The journal implements the standard syslog message levels. You can use either the priority name or its corresponding numeric value. In order of highest to lowest priority, these are:

  • 0: emerg
  • 1: alert
  • 2: crit
  • 3: err
  • 4: warning
  • 5: notice
  • 6: info
  • 7: debug

The above numbers or names can be used interchangeably with the -p option. Selecting a priority will display messages marked at the specified level and those above it.

1 Like

Thanks a lot, found that somewhere else. Now I have
journalctl -p info -b -u postgresql --since "600 min ago"
to get the priority info or higher. Unfortunately all messages from unit postgresql seem to be type info, .e.g
Database-System ready for connection
and
select * from non_existing_table
both produce a type “info” line.

Well, you’ve officially done more than me, you’ve got more experience! Well done!

I am unable to help you any further. In fact, today was the most I’ve worked with/spoken about journald as of yet.

So, very good luck to you further!

I’ve never been running PostgreSQL under Manjaro
But under Debian I remember log files where somewhere along

/opt/PostgreSQL/<ver e.g. 9.4>/data/pg_log*

Thank you, but meanwhile I believe, that it is different between DEBIAN- and Arch-based Distributions. On kUBUNTU I had all logs in /var/log/postgresql/ and the main package in /usr/share/postgresql/10/, not in /opt.

I’d appreciate if you or someone else would give it a try with manjaro, log-in to the database and
select pg_current_logfile()
I get an NULL response