1. Go to this page and download the library: Download stackify/log4php 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/ */
stackify / log4php example snippets
try {
$db->connect();
catch (DbException $ex) {
$logger->error('DB is not available', $ex);
}
<param name="debug" value="1" />
// Sample PHP Config
$config = array(
'Debug' => true,
'DebugLogPath' => '/path/to/log.log'
);
// 1. Converting PHP array to JSON String
// - String: {"Debug":true,"DebugLogPath":"/path/to/log.log"}
$jsonString = json_encode($config);
// 2. XML Encode the JSON String
// - ' is replaced with '
// - " is replaced with "
// - & is replaced with &
// - < is replaced with <
// - > is replaced with >
// - Encoded String: {"Debug":true,"DebugLogPath":"/path/to/log.log"}
// - Note: In case the string has new line ("\n") or a carriage return ("\r") character, you still need to escape it
// - \n should be replaced with or 

// - \r should be replaced with or 
// - Reference: https://stackoverflow.com/a/29924176/14542233
$xmlEncode = htmlspecialchars($jsonString, ENT_XML1 | ENT_QUOTES, 'UTF-8');
// 3. Add it as a value on XML Configuration
<param name="config" value="{"Debug":true,"DebugLogPath":"/path/to/log.log"}" />