You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CodeIgniter日志无法在本地浏览器/Git Bash显示,请求技术支持

Troubleshooting Missing CodeIgniter Logs

Let's walk through the most common fixes for when your CodeIgniter logs aren't showing up—this is a super common issue, so we'll get you sorted quickly.

  • Fix directory permissions first
    CodeIgniter needs write access to the application/logs folder to create log files. On Linux/macOS, open Git Bash and run:

    chmod 755 application/logs
    

    If that doesn't work, temporarily use chmod 777 application/logs to test (just remember to set it back to 755 afterward for security). On Windows, make sure the user running your web server (like IIS_IUSRS or Apache) has write permissions for the logs folder.

  • Watch the correct log file, not just the directory
    Your tail -f application/logs command is watching the directory itself, not the actual log file. CodeIgniter names logs like log-YYYY-MM-DD.php by default. Use this command instead to watch today's log:

    tail -f application/logs/log-$(date +%Y-%m-%d).php
    

    Also, note that the log file won't exist until the first log entry is written—so make sure you trigger the code that calls log_message before running this command.

  • Double-check your config.php settings

    • Confirm $config['log_threshold'] = 1; isn't commented out and there's no later line in the file overriding this value. A threshold of 1 should log all errors, which matches your log_message('error', ...) call.
    • Verify $config['log_path'] is set correctly (it defaults to APPPATH.'logs/', but if you changed it, ensure the path exists and is writable).
  • Test with a simple log message
    Your log_message('error', print_r($data, true)); looks valid, but maybe the code path isn't executing, or $data is causing an unexpected issue. Add a simple test line first:

    log_message('error', 'TEST: This is a sample error log entry');
    

    Run that code, then check if the log file appears. If the test works, your original $data variable might have something odd going on—but print_r($data, true) should handle most cases.

  • Check for server-level error suppression
    Open your root index.php file and make sure error reporting isn't being suppressed. Look for lines like error_reporting(0)—if you see that, change it to error_reporting(E_ALL); temporarily to ensure errors are being captured.

  • Check the server's PHP error log
    If CodeIgniter can't write to its own logs, it might log the failure to the server's PHP error log. On Linux, this is usually at /var/log/apache2/error.log or /var/log/nginx/error.log—check here for permission errors related to the application/logs folder.

内容的提问来源于stack exchange,提问作者Jasmin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:45:25