阅读带有颜色和粗体的导出日志

ana*_*nik 7 systemd journalctl

如何从journalctl -b -1 > bootlog.txt全彩色中检查导出的引导部分?默认导出格式会丢失所有颜色和粗体标记,这对于发现关键细节很重要。

可以使用 导出为 .json 和某种export格式journalctl -b -1 -o export > bootlog.export,但journalctl即使文件重命名为bootlog.journal并使用-D选项指向,也拒绝读取它。

人们如何分析导出的journalctl数据?

更新:我能够使用来自/sf/ask/1917850581/的 hack 在文件中获得彩色输出,以欺骗journalctl它在终端中运行:

script -q -c "journalctl -b -1 --no-pager" colored.txt > /dev/null
Run Code Online (Sandbox Code Playgroud)

less colored.txt然后正确显示这些颜色。但是,我必须多次杀死终端 - 调试script命令是一种可怕的体验。

小智 3

您正在寻找systemd-journal-remote.

如果将日志部分导出到使用以下命令调用的文件中foodump

journalctl --output=export --boot=-1 > foodump
Run Code Online (Sandbox Code Playgroud)

foodump将在Journal Export Format.

然后,您可以使用以下命令将其转换回普通日志文件:

systemd-journal-remote --output=foodump.journal foodump
Run Code Online (Sandbox Code Playgroud)

或者,在某些发行版(如 Debian)中:

/lib/systemd/systemd-journal-remote --output=foodump.journal foodump
Run Code Online (Sandbox Code Playgroud)

并使用以下命令查看它:

journalctl --file=foodump.journal
Run Code Online (Sandbox Code Playgroud)

在 Debian 上,您可以systemd-journal-remote使用apt-get install systemd-journal-remote. 在软呢帽上dnf install systemd-journal-remote

长话短说

德班:

journalctl --output=export --boot=-1 | \
  /lib/systemd/systemd-journal-remote --output=exported.journal -
Run Code Online (Sandbox Code Playgroud)

软呢帽:

journalctl --output=export --boot=-1 | \
  /usr/lib/systemd/systemd-journal-remote --output=exported.journal -
Run Code Online (Sandbox Code Playgroud)

查看它:

journalctl --file=exported.journal
Run Code Online (Sandbox Code Playgroud)

如需更多信息,请参阅手册