You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

树莓派4上Ubuntu 22.04服务器中无法找到/var/log/daemon.log等日志文件的问题咨询

树莓派4上Ubuntu 22.04服务器中无法找到/var/log/daemon.log等日志文件的问题咨询

Hey there! Let me walk you through why those log files are missing and how to get them back (or use the modern alternative if you prefer).

First off, Ubuntu 22.04 Server (including the Raspberry Pi variant) uses systemd-journald as its default logging system instead of the older syslog setup that generated files like /var/log/daemon.log and /var/log/debug. That’s why you don’t see them out of the box.

Here are two ways to handle this:

Option 1: Bring back the traditional log files

To restore those familiar log files, you’ll need to install and enable rsyslog, the tool that manages traditional syslog-style logging:

  • First, check if rsyslog is already installed by running this command:
    sudo apt list --installed | grep rsyslog
    
  • If it doesn’t show up, install it with:
    sudo apt update && sudo apt install rsyslog
    
  • Once installed, start and enable the service so it runs on boot:
    sudo systemctl start rsyslog
    sudo systemctl enable rsyslog
    

Wait a minute or two, then check /var/log again—you should see daemon.log pop up.

For /var/log/debug specifically, you might need to tweak the rsyslog config:

  • Open the config file with your favorite editor (like nano):
    sudo nano /etc/rsyslog.conf
    
  • Look for this section (it’ll be commented out with #):

    #*.=debug;\

    auth,authpriv.none;\
    news.none;mail.none -/var/log/debug
  • Remove the # from the start of each line to uncomment them, then save and exit (in nano, that’s Ctrl+O, Enter, then Ctrl+X).
  • Restart rsyslog to apply the change:
    sudo systemctl restart rsyslog
    

Now /var/log/debug should start being populated.

Option 2: Use the modern systemd journal instead

If you don’t mind skipping the traditional log files, you can access the same logs directly via journalctl, which is the native tool for systemd logging:

  • To view daemon-related logs (equivalent to daemon.log):
    journalctl -u daemon.*
    
  • To view debug-level logs (equivalent to debug):
    journalctl -p debug
    

You can even add flags like -f to follow the logs in real-time, just like tail -f on traditional log files!

备注:内容来源于stack exchange,提问作者wimphot

火山引擎 最新活动