1. Go to this page and download the library: Download tribeos/http-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tribeos / http-logger example snippets
/* Use the logger namespace */
use HttpLog\HttpLogger;
$logger = HttpLogger::create("file", "full+h", "logs/debug.log", false)::get();
HttpLogger::create("file", "full+h", "logs/debug.log", false);
/* The HttpLogger::get() can then be called from anywhere inside the project. */
$logger = HttpLogger::get();
/* Pure PHP example */
/* Create and fetch the logger instance */
$logger = HttpLogger::create("file", "full+h", "logs/debug.log", false)::get();
/* Output a response */
header("Content-Type: application/json");
echo json_encode( ["param" => "test"] );
/* Log the incoming request, outgoing response and possible errors */
$logger->log();
/* Defining a logger with a custom filter */
$logger = HttpLogger::create("file", "date|url|method|ip|", "logs/debug.log", false)::get();
/* Create and fetch an error-only logger instance */
$logger = HttpLogger::create("file", "error", "logs/debug.log", false)::get();
print_r($undefined);
md5();
no_such_function();
/* Create and fetch the logger instance */
$logger = HttpLogger::create("file", "full+h", "logs/debug.log", false)::get();
$logger->warning("Testing a sample warning.");
$logger->info("This is an informational message.");
$logger->fatal("This fatal error will stop program execution.");
/* Create and fetch an error-only logger instance */
$logger = HttpLogger::create("file", "error", "logs/debug.log", false)::get();
/* A mix of regular and user-defined errors */
$logger->info("This is an informational message.");
print_r($undefined_variable);
$logger->fatal("This is a fatal error.");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.