Mac OS X 上的 PostgreSQL 日志在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2563494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 22:27:07  来源:igfitidea点击:

Where are the PostgreSQL logs on Mac OS X?

postgresqlloggingmacos

提问by basilikode

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.

我想查看 PostgreSQL 日志文件以查看我的应用程序向它们写入的内容,但我找不到它们。

Any ideas?

有任何想法吗?

采纳答案by Jeremiah Peschka

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

在 OS X 上,如果您使用的是 PostgreSQL 的 EnterpriseDB 安装,您的日志文件将位于 /Library/PostgreSQL/8.4/data/pg_log

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

当然,您需要将 8.4 替换为您正在运行的任何版本号。

回答by Mikko Ohtamaa

On OSX Homebrew installation the log can be found at:

在 OSX Homebrew 安装中,可以在以下位置找到日志:

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

or for older version of postgres (< 9.6)

或者对于旧版本的 postgres (< 9.6)

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

回答by Frank Heikens

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"

就我而言,它在“/Library/PostgreSQL/8.4/data/pg_log”中

回答by lambshaanxy

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

plist用于启动你的Postgres上的引导也可以设置日志文件:

$ 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.

所以在这种情况下,/usr/local/var/postgres/server.log.

回答by nofinator

If you are using Postgres.app, you can find the Data Directory location in the Preferences dialog box. In that directory, the log is at postgres-server.log.

如果您使用Postgres.app,您可以在首选项对话框中找到数据目录位置。在该目录中,日志位于postgres-server.log.

For example, on my machine, the log is at /Users/nofinator/Library/Application Support/Postgres/var-9.4/postgres-server.log.

例如,在我的机器上,日志位于/Users/nofinator/Library/Application Support/Postgres/var-9.4/postgres-server.log.

回答by plang

I have different Postgresql versions installed on my mac (with macports), and all the logs can be found here

我的 mac 上安装了不同的 Postgresql 版本(使用 macports),所有日志都可以在这里找到

/opt/local/var/log/postgresql84/postgres.log
/opt/local/var/log/postgresql91/postgres.log
/opt/local/var/log/postgresql92/postgres.log

回答by Martin Sommer

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

Postgresapp 9.3.5.1 及更高版本保留服务器日志。日志位于数据目录中,名为 postgres-server.log。

回答by systempuntoout

Look in /var/log/pg_log/folder

查看/var/log/pg_log/文件夹