use Monolog\Logger; use Monolog\Handler\StreamHandler; $log = new Logger('name'); $log->pushHandler(new StreamHandler('/path/to/your.log', Logger::WARNING)); $log->warning('Foo'); $log->error('Bar');
use Logger; use LoggerAppenderFile; $logger = Logger::getLogger('myLogger'); $fileAppender = new LoggerAppenderFile('myFileAppender'); $fileAppender->setFile('/path/to/your.log'); $logger->addAppender($fileAppender); $logger->info('Hello, World!');
include 'KLogger.php'; $log = new KLogger('/path/to/your.log', KLogger::INFO); $log->logInfo('Hello, World!'); $log->logError('Oops, something went wrong.');In conclusion, the above examples of PHP code demonstrate three different logging libraries that are commonly used for logging messages in PHP applications. These libraries provide various logging features, including logging to different targets, organizing and categorizing logs, and recording messages at different levels of severity.