xuh*_*dev 16 systemd journalctl
journalctl
没有颜色的输出确实看起来很乱。是否可以为其输出添加颜色?在我的系统上,似乎只有重要的行被突出显示。甚至dmesg
可以通过添加--color
开关来输出颜色!
小智 11
安装ccze,然后像这样使用它:
journalctl -b -k -f | ccze [-A] [-o nolookups]
Run Code Online (Sandbox Code Playgroud)
解释:
-A, --raw-ansi
If one wants to enable raw ANSI color sequences instead of using curses, this option does just that.
-o, --options OPTIONS...
However, lookups is an option that might be better to disable. When on, ccze will try to look up usernames, service
names, and lots of other stuff, which will slow down coloring a great deal. If one is piping a long log through ccze,
this option might be turned off [nolookups] to speed up the process.
Run Code Online (Sandbox Code Playgroud)
的颜色支持journalctl
记录在man journalctl
:
输出到 tty 时,根据优先级对行进行着色:级别 ERROR 及更高级别的行着色为红色;级别 NOTICE 和更高级别的行被突出显示;其他线路正常显示。
那来自 systemd 229。如手册页中所示,没有其他内置颜色控件用于journalctl
.
小智 7
我用于ccze
所有日志。
journalctl -b -k -f | ccze
journalctl -b -k -f | ccze -A
Run Code Online (Sandbox Code Playgroud)
tail -f /etc/nginx/logs/access.log | ccze
tail -f /etc/unbound/unbound.log | ccze
Run Code Online (Sandbox Code Playgroud)
将日志导出为 HTML 并将其保存到 /root/syslog.html:
ccze -h -o nolookups /root/syslog.html
Run Code Online (Sandbox Code Playgroud)
希望对你有帮助。
小智 6
长期寻找答案,我实际上找到了对我有用的方法(使用Rails日志和journalctl)\xe2\x80\x93只需添加--all选项。
\njournalctl -u puma --all\n
Run Code Online (Sandbox Code Playgroud)\n来自联机帮助页:
\n\n\nRun Code Online (Sandbox Code Playgroud)\n-a, --all\n Show all fields in full, even if they include unprintable characters \n or are very long. By default, fields with unprintable characters \n are abbreviated as "blob data". (Note that the pager may escape \n unprintable characters again.)\n
归档时间: |
|
查看次数: |
17151 次 |
最近记录: |