gpt4 book ai didi

php - 如何在 Codeigniter 中更改日志文件扩展名

转载 作者:行者123 更新时间:2023-12-01 11:20:16 25 4
gpt4 key购买 nike

我看过其他关于 Codeigniter 错误记录 (here) 的帖子,但我的问题有点不同。出于某种原因,我所有的日志文件都被保存为 .php,但我找不到导致这种情况发生的代码部分。我在 repo 协议(protocol)本身和大量谷歌搜索中进行了相当广泛的搜索,但看不到任何非常不寻常的东西。

提前致谢。

最佳答案

您可以通过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';

希望对您有所帮助。

关于php - 如何在 Codeigniter 中更改日志文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44722921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com