CodeIgniter Forums
CI4 ,Change Log Message FileHandler - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI4 ,Change Log Message FileHandler (/showthread.php?tid=88810)



CI4 ,Change Log Message FileHandler - dhiya as - 11-11-2023

hi, 
how to change log message when page not found?
into the log file , message "Class initialized using 'CodeIgniter\Session\Handlers\FileHandler' driver." 
i want to change the message include url.


RE: CI4 ,Change Log Message FileHandler - kenjis - 11-12-2023

If you want to know the 404 URI, I recommend you see Web server log files.

If you remove 404 from $ignoreCodes in Config/Exceptions.php, the 404 Exception will be logged.
But if it is in production mode, the URI path is not included in the log. So useless.

PHP Code:
--- a/app/Config/Exceptions.php
+++ b/app/Config/Exceptions.php
@@ -31,+31,@@ class Exceptions extends BaseConfig
      
Any status codes here will NOT be logged if logging is turned on.
      By default, only 404 (Page Not Foundexceptions are ignored.
      */
-
    public array $ignoreCodes = [404];
+
    public array $ignoreCodes = [];

    /**
      * -------------------------------------------------------------------------- 

If v4.5.0 is released, the HTTP method and URI path will be logged:
Quote:CRITICAL - 2023-11-12 10:05:01 --> Page Not Found
[Method: GET, Route: xxx]
in SYSTEMPATH/CodeIgniter.php on line 931.



RE: CI4 ,Change Log Message FileHandler - dhiya as - 11-16-2023

(11-12-2023, 03:10 AM)kenjis Wrote: If you want to know the 404 URI, I recommend you see Web server log files.

If you remove 404 from $ignoreCodes in Config/Exceptions.php, the 404 Exception will be logged.
But if it is in production mode, the URI path is not included in the log. So useless.

PHP Code:
--- a/app/Config/Exceptions.php
+++ b/app/Config/Exceptions.php
@@ -31,+31,@@ class Exceptions extends BaseConfig
      
Any status codes here will NOT be logged if logging is turned on.
      By default, only 404 (Page Not Foundexceptions are ignored.
      */
-
    public array $ignoreCodes = [404];
+
    public array $ignoreCodes = [];

    /**
      * -------------------------------------------------------------------------- 

If v4.5.0 is released, the HTTP method and URI path will be logged:
Quote:CRITICAL - 2023-11-12 10:05:01 --> Page Not Found
[Method: GET, Route: xxx]
in SYSTEMPATH/CodeIgniter.php on line 931.


thanks kenjis ,but can i replace the default message before save into log file?
not just for page not found, but all message log,


RE: CI4 ,Change Log Message FileHandler - kenjis - 11-16-2023

Extend Logger.
See https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html


RE: CI4 ,Change Log Message FileHandler - dhiya as - 11-16-2023

(11-16-2023, 01:41 AM)kenjis Wrote: Extend Logger.
See https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html

thans kenjis ,
before i extend the logger,

just a suggestion, maybe in the next feature, 
the uri can be included in every type message log that occurs..
so that we can quickly analyze which URLs are problematic, 
or which URLs have been attacked

(11-16-2023, 02:09 AM)dhiya as Wrote:
(11-16-2023, 01:41 AM)kenjis Wrote: Extend Logger.
See https://codeigniter4.github.io/CodeIgniter4/extending/core_classes.html

thans kenjis ,
before i extend the logger,

just a suggestion, maybe in the next feature, 
the uri can be included in every type message log that occurs..
so that we can quickly analyze which URLs are problematic, 
or which URLs have been attacked



example i look into the log 
CRITICAL - 2023-11-16 07:45:02 --> The action you requested is not allowed.
in SYSTEMPATH\Security\Security.php on line 300.
1 SYSTEMPATH\Security\Security.php(300): CodeIgniter\Security\Exceptions\SecurityException::forDisallowedAction()
2 SYSTEMPATH\Filters\CSRF.php(56): CodeIgniter\Security\Security->verify()
3 SYSTEMPATH\Filters\Filters.php(184): CodeIgniter\Filters\CSRF->before()
4 SYSTEMPATH\CodeIgniter.php(477): CodeIgniter\Filters\Filters->run()
5 SYSTEMPATH\CodeIgniter.php(361): CodeIgniter\CodeIgniter->handleRequest()
6 FCPATH\index.php(79): CodeIgniter\CodeIgniter->run()

i dont know what the url access


RE: CI4 ,Change Log Message FileHandler - kenjis - 11-16-2023

@dhiya as
The feature has been implemented in 4.5 branch.
https://github.com/codeigniter4/CodeIgniter4/pull/8108


RE: CI4 ,Change Log Message FileHandler - dhiya as - 11-16-2023

(11-16-2023, 02:51 AM)kenjis Wrote: @dhiya as
The feature has been implemented in 4.5 branch.
https://github.com/codeigniter4/CodeIgniter4/pull/8108

ok,,thank you kenjis..