Welcome Guest, Not a member yet? Register   Sign In
CI4 ,Change Log Message FileHandler
#1

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.
Reply
#2

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.
Reply
#3

(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,
Reply
#4

Extend Logger.
See https://codeigniter4.github.io/CodeIgnit...asses.html
Reply
#5

(This post was last modified: 11-16-2023, 02:11 AM by dhiya as.)

(11-16-2023, 01:41 AM)kenjis Wrote: Extend Logger.
See https://codeigniter4.github.io/CodeIgnit...asses.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/CodeIgnit...asses.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
Reply
#6

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

(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..
Reply




Theme © iAndrew 2016 - Forum software by © MyBB