【问题标题】:View journalctl logs of running service查看运行服务的 journalctl 日志
【发布时间】:2018-09-24 12:31:22
【问题描述】:

我正在使用sudo journalctl -u some-service -f 查看服务的日志。但是,当服务运行时,最后一条日志始终是以下形式:

***Plenty of logs from previous instance of Some Service*** Apr 14 09:03:05 user-computer systemd[1]: Stopped Some Service. Apr 14 09:03:35 user-computer systemd[1]: Started Some Service.

我期望看到的:

***Plenty of logs from previous instance of Some Service*** Apr 14 09:03:05 user-computer systemd[1]: Stopped Some Service. Apr 14 09:03:35 user-computer systemd[1]: Started Some Service. ***New logs from current instance of Some Service***

为什么我看不到当前运行的服务实例的日志?只有在我停止/重新启动服务后,我才能看到来自该实例的日志。

请帮忙。

【问题讨论】:

    标签: linux ubuntu systemd


    【解决方案1】:

    问题是特定于应用程序的,与 systemd 或 journalctl 无关。

    对于我的 Python 服务,我不得不禁用输出缓冲区:

    [Service]
    StandardOutput=journal
    StandardError=journal
    Environment="PYTHONUNBUFFERED=x"
    

    对于我的 PHP 应用程序,我只需在内容被刷新之前添加一个换行符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-24
      • 1970-01-01
      • 2022-07-03
      • 2022-08-05
      • 2022-11-03
      • 2019-03-12
      • 1970-01-01
      相关资源
      最近更新 更多