如何在Codeigniter

时间:2017-06-23 13:41:17

标签: php codeigniter logging codeigniter-2

我已经看过有关Codeigniter错误记录的其他帖子(here),但我的问题有点不同。出于某种原因,我的所有日​​志文件都保存为.php,我无法找到代码的哪一部分导致这种情况发生。我在回购邮件本身和很多谷歌搜索中进行了相当广泛的搜索,但却看不到任何与众不同的东西。

提前致谢。

2 个答案:

答案 0 :(得分:3)

您可以按application/config/config.php进行更改。请查看下面提到的代码并设置自定义扩展程序。

/*
  |--------------------------------------------------------------------------
  | Log File Extension
  |--------------------------------------------------------------------------
  |
  | The default filename extension for log files. The default 'php' allows for
  | protecting the log files via basic scripting, when they are to be stored
  | under a publicly accessible directory.
  |
  | Note: Leaving it blank will default to 'php'.
  |
 */
$config['log_file_extension'] = '';

您还可以根据您的要求生成日志,如下所述。

/*
  |--------------------------------------------------------------------------
  | Error Logging Threshold
  |--------------------------------------------------------------------------
  |
  | You can enable error logging by setting a threshold over zero. The
  | threshold determines what gets logged. Threshold options are:
  |
  | 0 = Disables logging, Error logging TURNED OFF
  | 1 = Error Messages (including PHP errors)
  | 2 = Debug Messages
  | 3 = Informational Messages
  | 4 = All Messages
  |
  | You can also pass an array with threshold levels to show individual error types
  |
  |     array(2) = Debug Messages, without Error Messages
  |
  | For a live site you'll usually only enable Errors (1) to be logged otherwise
  | your log files will fill up very fast.
  |
 */
$config['log_threshold'] = 1;

设置自定义目录以保存日志文件。

/*
  |--------------------------------------------------------------------------
  | Error Logging Directory Path
  |--------------------------------------------------------------------------
  |
  | Leave this BLANK unless you would like to set something other than the default
  | application/logs/ directory. Use a full server path with trailing slash.
  |
 */
$config['log_path'] = '';

这将用于设置日志文件的权限。

/*
  |--------------------------------------------------------------------------
  | Log File Permissions
  |--------------------------------------------------------------------------
  |
  | The file system permissions to be applied on newly created log files.
  |
  | IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
  |            integer notation (i.e. 0700, 0644, etc.)
 */
$config['log_file_permissions'] = 0644;

这将用于为每个日志条目设置日期格式。

/*
  |--------------------------------------------------------------------------
  | Date Format for Logs
  |--------------------------------------------------------------------------
  |
  | Each item that is logged has an associated date. You can use PHP date
  | codes to set your own date formatting
  |
 */
$config['log_date_format'] = 'Y-m-d H:i:s';

我希望这会对你有所帮助。

答案 1 :(得分:1)

打开文件/application/config/config.php并搜索$config['log_file_extension']。 用你喜欢的扩展名填空值。

| The default filename extension for log files. The default 'php' allows for
| protecting the log files via basic scripting, when they are to be stored
| under a publicly accessible directory.
|
| Note: Leaving it blank will default to 'php'.