Where are the PostgreSQL logs on Mac OS X?

2019-01-21 06:17发布

I would like to take a look at the PostgreSQL log files to see what my app writes to them but I can't find them.

Any ideas?

8条回答
啃猪蹄的小仙女
2楼-- · 2019-01-21 06:43

On OS X, if you're using the EnterpriseDB installation of PostgreSQL, your log files will be in /Library/PostgreSQL/8.4/data/pg_log

Of course, you'll want to substitute 8.4 for whichever version number you're running.

查看更多
做个烂人
3楼-- · 2019-01-21 06:44

The plist used to launch your Postgres on boot may also set the logfile:

$ dir ~/Library/LaunchAgents
org.postgresql.postgres.plist

$ cat ~/Library/LaunchAgents/org.postgresql.postgres.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  [...]
  <key>StandardErrorPath</key>
  <string>/usr/local/var/postgres/server.log</string>
</dict>
</plist>

So in this case, /usr/local/var/postgres/server.log.

查看更多
We Are One
4楼-- · 2019-01-21 06:47

Postgresapp 9.3.5.1 and later keep a server log. The log is inside the data directory, named postgres-server.log.

查看更多
一夜七次
5楼-- · 2019-01-21 06:53

On OSX Homebrew installation the log can be found at:

/usr/local/var/postgres/server.log

or

/usr/local/var/log/postgres.log 

(First one is version < 9.6 and second one is version >= 9.6 of PostgreSQL)

查看更多
Summer. ? 凉城
6楼-- · 2019-01-21 07:02

Look in /var/log/pg_log/ folder

查看更多
你好瞎i
7楼-- · 2019-01-21 07:07

Just ask your database:

SELECT 
    * 
FROM 
    pg_settings 
WHERE 
    category IN( 'Reporting and Logging / Where to Log' , 'File Locations')
ORDER BY 
    category,
    name;

In my case, it's in "/Library/PostgreSQL/8.4/data/pg_log"

查看更多
登录 后发表回答