How to change log file extension in Codeigniter
You can change it by application/config/config.php
. Please find below mention code and set your custom extension.
/* |-------------------------------------------------------------------------- | 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'] = '';
You can also generate logs depends on your requirement as describe below.
/* |-------------------------------------------------------------------------- | 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;
Set custom directory to save your log files.
/* |-------------------------------------------------------------------------- | 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'] = '';
This will be used to set the permissions to log files.
/* |-------------------------------------------------------------------------- | 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;
This will be used to set date format for each log entry.
/* |-------------------------------------------------------------------------- | 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';
I hope this will help you.
Open the file /application/config/config.php
and search for $config['log_file_extension']
.Fill the empty value with your favourite 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'.