如何通过journalctl合并多个期刊的输出?

Vla*_*lav 9 systemd

我需要查看所有 postgresql 日志。我尝试:

$ journalctl -f -u postgresql.service SYSLOG_IDENTIFIER=postgres
-- Logs begin at ?? 2013-03-06 00:57:40 KRAT. --
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  database system was interrupted; last known up at 2013-08-11 20:12:28 KRAT
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  database system was not properly shut down; automatic recovery in progress
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  record with zero length at 5/DACF208
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  redo is not required
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  autovacuum launcher started
??? 11 23:41:07 nuzzflonk postgres[2432]: LOG:  database system is ready to accept connections
-- Reboot --
??? 19 20:23:22 nuzzflonk postgres[2361]: FATAL:  the database system is starting up
??? 19 20:23:22 nuzzflonk postgres[2361]: LOG:  database system was shut down at 2013-08-19 20:21:25 KRAT
??? 19 20:23:22 nuzzflonk postgres[2361]: LOG:  autovacuum launcher started
??? 19 20:23:22 nuzzflonk postgres[2361]: LOG:  database system is ready to accept connections
Run Code Online (Sandbox Code Playgroud)

但:

$ journalctl -f SYSLOG_IDENTIFIER=postgres 
-- Logs begin at ?? 2013-03-06 00:57:40 KRAT. --
??? 24 10:50:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 11:10:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 11:20:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 11:30:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 11:40:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 11:50:08 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 12:00:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 12:30:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 12:40:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
??? 24 12:50:07 nuzzflonk postgres[2361]: LOG:  unexpected EOF on client connection with an open transaction
Run Code Online (Sandbox Code Playgroud)

如何合并两个期刊?

UPD:解决了。$ journalctl -f SYSLOG_IDENTIFIER=postgres显示所有期刊。

TCB*_*B13 8

要组合多个期刊的输出,您只需使用以下-u选项将它们添加到您的命令中:

journalctl -u nginx.service -u mysql.service -f
Run Code Online (Sandbox Code Playgroud)

无需使用SYSLOG_IDENTIFIER,因为在大多数情况下这可能不是您想要的。