I have used Monologing before and not had a problem however with this application no log files are being created even though I have monolog warnings and notices throughout the application but nothing has been created, It might also be worth noting that I have session variables created but session files in the "var" file however I am not sure if that is the same issue. I am using xampp as my development environment.
No errors have been output and I have var_dump the logger to make sure it has been created properly and there does not seem to be an issue there.
Here is the file structure:
Any help would be appreciated
/* Settings file */
// Get log file path
$log_file_path = '/Football_Trivia_Game/logs/';
// Define log file path
define('LOG_FILE_PATH', $log_file_path);
/* Dependencies.php */
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FingersCrossedHandler;
// Create container for two different kind of loggers
// One logger will handles notices and the other handles warning
$container['logger'] = function() {
// Instantiate logger
$logger = new Logger('logger');
// Notices logger
// Set notices log path
$notices_log = LOG_FILE_PATH . 'notices.log';
// Create stream handler for notices logger
$stream_notices = new StreamHandler($notices_log, Logger::NOTICE);
// Push stream handler into logger object
$logger->pushHandler($stream_notices);
// Warning logger
// Set warning log path
$warning_log = LOG_FILE_PATH . 'warnings.log';
// Create stream handler for warnings logger
$stream_warnings = new StreamHandler($warning_log, Logger::WARNING);
// Push stream handler into logger object
$logger->pushHandler($stream_warnings);
$logger->pushProcessor(function ($record) {
$record['context']['sid'] = session_id();
return $record;
});
// Return looger
return $logger;
};
/* This is an example of an attempt to use the logger in the database connection /*
try {
$pdo_handle = new \PDO($host_details, $username, $password, $pdo_attributes);
$this->db_handle = $pdo_handle;
$this->logger->notice("Connected to database successfully!");
}
catch(\PDOException $exception_object) {
trigger_error('Error connection to the database');
$pdo_error = 'Error connection to the database';
$this->logger->warning("Failed to connect to database!");
}