温馨提示×

Compton配置中的日志输出如何查看

小樊
41
2025-12-12 21:39:09
栏目: 编程语言

Compton 日志输出查看与配置

一、快速定位方式

  • 若通过终端手动启动,Compton 默认把运行信息输出到标准输出 stdout标准错误 stderr,直接在该终端即可看到日志。若希望落盘,需显式重定向输出到文件。
  • 若由 systemd 管理(服务名为compton.service),使用 journalctl 查看:journalctl -u compton.service;只看最近 10 条:journalctl -u compton.service -n 10;只看错误级别:journalctl -p 3 -b -o cat | grep compton。
  • 若未使用服务,仍可在系统日志中检索:grep -i compton /var/log/syslog 或 /var/log/messages。
  • 注意:Compton 默认不会自动生成日志文件,需要你通过命令行参数或重定向将日志写入文件。

二、在配置中启用与输出到文件

  • 设置日志级别:在启动命令或配置中增加 --log-level=debug(可选值如 error、warn、info、debug,视版本支持而定),获取更详细输出。
  • 重定向输出到文件:例如在会话启动脚本或终端中执行 compton --log-level=debug > ~/.config/compton/compton.log 2>&1 &;随后可用 tail -f ~/.config/compton/compton.log 实时查看。
  • 配置文件位置:常见为 ~/.config/compton.conf/etc/xdg/compton.conf;部分版本/发行版支持在配置中指定日志文件路径与级别(若所用版本或构建不支持,则需依赖命令行与重定向)。

三、常见故障排查命令

  • 确认进程:ps -e | grep compton;必要时 killall compton 结束旧进程后再启动。
  • 查看服务状态与日志:systemctl status compton;journalctl -u compton.service -b 查看本次启动日志。
  • 仅看错误:journalctl -p 3 -b -o cat | grep compton。
  • 若怀疑被内核记录:dmesg | grep -i compton(通常无输出属正常)。

四、实用示例

  • 手动前台调试:compton --config ~/.config/compton.conf --log-level=debug
  • 后台并记录日志:compton --config ~/.config/compton.conf --log-level=debug > ~/.config/compton/compton.log 2>&1 &
  • 实时跟踪日志:tail -f ~/.config/compton/compton.log
  • 查看服务日志:journalctl -u compton.service -b
  • 只看错误:journalctl -p 3 -b -o cat | grep compton

0