Use "System Log" to log HTTP requests

Components

Labels

Description

In-Portal has a functionality to log all incoming HTTP requests. Logging can be enabled by specifying path to log file in DBG_REQUREST_LOG constant in /system/debug.php.

After using this functionality for a while here are few things I've noticed:

  • Pros:

    • GET/POST/COOKIE is recorded

    • some other information to identify user, who made a request is recorded

  • Cons:

    • hard to analyze, because in a result a large text file is created

    • HTTP headers not recorded

Gladly in INP-811 task we've create flexible logging engine that logs same information but in easily browsable/searchable form.

I recommend to use this "System Log" section to log all information. But we also need to improve "System Log" section by adding ability to log HTTP headers along with HTTP requests.

Context Information

None

Additional information (do not use)

None

Attachments

3

Activity

Show:

[API] Administrator August 27, 2013 at 12:55 PM

User committed a fix to 5.3.x. Commit Message:

Fixes - Use "System Log" to log HTTP requests
1. Commit on behalf of Erik

Alex August 27, 2013 at 12:53 PM

Works, following things were changed:

  1. Changed condition, that tells when to log.

  2. Trigger warning in case if it's impossible to write Http Request due disabled "System Log".

  3. Fixed typo error in "DBG_REQUEST_LOG" constant name.

  4. Changed default value & comment of "DBG_REQUEST_LOG" constant to indicate combined usage with "System Log".

Erik S. August 23, 2013 at 5:04 PM

All necessary changes done.
Patch attached - log_http_requests_to_system_log_v2.patch 6 kB

Ready for Testing

Alex July 30, 2013 at 4:57 PM
Edited

Following wasn't implemented.

  1. System Log is already capable of logging Get/Post/Cookie along with a message by calling kLogger::addRequestData. This way "HTTP_REQUEST" text can be specified as log message text and request data will be automatically stored in dedicated column by calling kLogger::addRequestData on a log message object.

  2. Method kMainTagProcessor::_requestHeaders should be moved to kHttpQuery::getHeaders and made public.

  3. Method kHttpQuery::getHeaders must be used:

    • in place of kMainTagProcessor::_requestHeaders

    • in kLogger::addRequestData to put headers in 'HEADERS' key in $request_data array.

P.S.

To be able to call any method on a log record prior to saving to database it's required to pass extra parameter to kApplication::log method.

Erik S. July 26, 2013 at 12:33 PM

All done. Attached patch
log_http_requests_to_system_log.patch 26/Jul/13 3:32 PM 4 kB

Ready for Testing

Fixed

Details

Priority

Assignee

Reporter

Developer

Reviewer

Change Log Group

Changed

Change Log Message

Patch Instructions

Patches must be submitted through Phabricator.

Commit Revision

15,957

Story Points

Fix versions

Created April 23, 2013 at 1:30 PM
Updated February 3, 2025 at 8:10 AM
Resolved August 27, 2013 at 12:55 PM