12

我似乎无法弄清楚为什么 codeigniter 没有记录我的 log_messages

在配置中:

$config['log_threshold'] = 4;
$config['log_path'] = '/var/log/mydlp.log';

在脚本中:

log_message('error','here');

文件位置:

-rw-rw-rw- 1 root  root    0 2012-12-05 13:10 mydlp.log

当我收到日志消息时,我什么也没得到。

这是我的 /var 和 /var/log 的目录结构

 drwxr-xr-x  6 root root  4096 2012-12-05 13:10 log
 drwxr-xr-x  14 root root  4096 2012-01-04 14:38 var

我在这里做错了吗?

4

2 回答 2

15

$config['log_path']应该是目录的路径,而不是文件。CI 以log-2012-12-05.php. 尝试一个目录的路径,并确保包含一个斜杠。

/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '/var/log/ci_logs/';
于 2012-12-05T18:27:09.277 回答
3

问题是 SELinux 检查这篇文章。

你试试这个:

# Ownership
sudo chown apache:apache -R /data/www/html/sites/mysite
cd /data/www/html/sites/mysite

# File permissions, recursive
find . -type f -exec chmod 0644 {} \;

# Dir permissions, recursive
find . -type d -exec chmod 0755 {} \;

# SELinux serve files off Apache, resursive
sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R

# Allow write only to specific dirs
sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R

https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/

于 2019-02-18T20:39:47.613 回答