public function testThreshold() { Logger::configure('configurators/test1.xml'); $root = Logger::getRootLogger(); self::assertEquals(LoggerLevel::getLevelWarn(), $root->getLevel()); $appender = $root->getAppender("default"); self::assertTrue($appender instanceof LoggerAppenderEcho); $layout = $appender->getLayout(); self::assertTrue($layout instanceof LoggerLayoutSimple); $threshold = $appender->getThreshold(); self::assertTrue($threshold instanceof LoggerLevel); $e = LoggerLevel::getLevelWarn(); self::assertEquals($e, $threshold); $appender = $root->getAppender("blub"); self::assertTrue($appender instanceof LoggerAppenderEcho); $layout = $appender->getLayout(); self::assertTrue($layout instanceof LoggerLayoutSimple); $threshold = $appender->getThreshold(); self::assertTrue($threshold instanceof LoggerLevel); $e = LoggerLevel::getLevelInfo(); self::assertEquals($e, $threshold); $filter = $appender->getFilter(); self::assertTrue($filter instanceof LoggerFilterLevelRange); $filter2 = $filter->getNext(); self::assertTrue($filter2 instanceof LoggerFilterDenyAll); $threshold = Logger::getHierarchy()->getThreshold(); self::assertTrue($threshold instanceof LoggerLevel); $e = LoggerLevel::getLevelWarn(); self::assertEquals($e, $threshold); $hierarchy = Logger::getHierarchy(); $map = $hierarchy->getRendererMap(); $clazz = $map->getByClassName('Fruit2'); self::assertTrue($clazz instanceof FruitRenderer2); }
function get_logger() { require_once EZBOSS_THIRDPARTY_PATH . '/Apache/log4php/Logger.php'; Logger::configure(EZBOSS_WEBROOT . '/config/appender_dailyfile.properties'); $logger = Logger::getRootLogger(); return $logger; }
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) { parent::__construct($request, $response, $invokeArgs); date_default_timezone_set(DATE_ZONE); Logger::configure(LOG_ERROR); $this->_logger = Logger::getLogger(__CLASS__); }
function __construct($jsonPath) { include $this->loggerPath; Logger::configure($this->loggerConfigPath); $this->logger = Logger::getLogger("main"); $this->jsonFilePath = $jsonPath; }
/** * Loads the log4php library. */ function lib_log4php_load() { require LIB_LOG4PHP_PATH . '/Logger.php'; // start logging Logger::configure(LIB_LOG4PHP_CONFIGFILE_PATH); $logger = Logger::getLogger('system.libs.log4php'); $logger->info('log4php started'); }
public function setup() { // for compatibility / remove and enable only the plugins you want $this->enableAllPluginsExcept(array()); // Set up logging - use different config for test environment $logConfig = sfConfig::get('sf_environment') == 'test' ? 'log4php_test.properties' : 'log4php.properties'; Logger::configure(dirname(__FILE__) . '/' . $logConfig, 'OrangeHRMLogConfigurator'); }
public function __construct($logger = 'default') { $pathXML = LIB . DS . 'log' . DS . 'config.xml'; $configurator = new LoggerConfiguratorDefault(); $config = $configurator->parse($pathXML); Logger::configure($config); $this->logger = Logger::getLogger($logger); }
/** * Configures log4php and the PHP error & exception handlers * to log all errors and exceptions through log4php. * * @param string $log4phpConfiguration * the log4php configuration filename */ public static final function configure($log4phpConfiguration) { \Logger::configure($log4phpConfiguration); set_error_handler('\\PHPYAM\\libs\\LoggerUtils::errorHandler'); set_exception_handler('\\PHPYAM\\libs\\LoggerUtils::exceptionHandler'); // TODO: add register_shutdown_function() for non-catchable errors? // http://phpfunk.com/php/capture-fatal-php-errors-for-logging/ }
public function __construct() { date_default_timezone_set(DATE_ZONE); Logger::configure(LOG_ERROR); $this->logger = Logger::getLogger(__CLASS__); $this->logger->debug("Inicializando la base de datos."); $this->initDB(); }
protected function getLogger() { if (null == $this->_logger) { $logfile = self::$_logname . "log.xml"; Logger::configure(CONF_PATH . DIRECTORY_SEPARATOR . $logfile); $this->_logger = Logger::getRootLogger(); } return $this->_logger; }
public final function __construct() { \Logger::configure("..\\config\\logger.xml"); $this->log = \Logger::getLogger(__CLASS__); /** @var $this->Session Session */ $this->Session = \src\singleton\Session::inst(); $this->Session->Start(); $this->RenderPage(); }
/** * 初始化Log4php */ public function __construct() { $config =& get_config(); if (is_numeric($config['log_threshold'])) { $this->_threshold = $config['log_threshold']; } require_once LOG4PHP_PATH . 'Logger.php'; Logger::configure(APPPATH . 'config/log_dailyfile.xml'); }
function initialize_logger($name) { if (!IN_DEBUG) { return; } global $logger; Logger::configure(array('rootLogger' => array('appenders' => array('default')), 'appenders' => array('default' => array('class' => 'LoggerAppenderRollingFile', 'layout' => array('class' => 'LoggerLayoutPattern', "params" => array("ConversionPattern" => "%d{ISO8601} [%p] %m (at %F line %L)%n")), 'params' => array('file' => join_paths(QWP_LOG_DIR, $name . '.log'), 'append' => true, 'MaxFileSize' => '10MB', 'MaxBackupIndex' => '3'))))); $logger = Logger::getRootLogger(); }
public static function init() { if (self::$_initialized === TRUE) { return; } Logger::configure(__DIR__ . '/../config/log4php/config.xml'); self::$_log = Logger::getLogger(__CLASS__); self::$_initialized = TRUE; }
private function __construct() { $this->logger = new NullLog4php(); $this->sqlLogger = new NullLog4php(); if (file_exists($f = ROOT_DIR . 'config/log4php.config.xml')) { Logger::configure($f); $this->logger = Logger::getLogger('default'); $this->sqlLogger = Logger::getLogger('sql'); } }
private static function init_log() { $pathLogFile = self::$config['pathLogFile']; if ($pathLogFile) { // Tell log4php to use our configuration file. Logger::configure($pathLogFile); } else { die("日志初始化失败。"); } }
/** * Logs a message and adds <br /> html tag. * @param string $level Log level * @param string $message Log message */ public static function log($level, $message) { // check if to create new logger instance if (Log::$logger == null) { Logger::configure(realpath(dirname(__FILE__)) . '/log.xml'); Log::$logger = Logger::getLogger('main'); } // call log function in logger instance call_user_func(array(Log::$logger, $level), $message); }
public function _initLogger() { require_once APPLICATION_PATH . "/application/library/Log/Logger.php"; Logger::configure(APPLICATION_PATH . "/conf/logconf.php"); $logger = Logger::getRootLogger(); Yaf_Registry::set('logger', $logger); // Logger::configure(APPLICATION_PATH . "/conf/statlogconf.php"); // $statLogger = Logger::getRootLogger(); // Yaf_Registry::set('statLogger', $statLogger); }
protected function init() { if ($this->initialized) { return; } \Logger::configure($this->pixie->config->get('logger')); \GWTPHPContext::getInstance()->setServicesRootDir(realpath(dirname(__FILE__) . '/../../gwtphp-maps')); \GWTPHPContext::getInstance()->setGWTPHPRootDir(GWTPHP_DIR); $this->initialized = true; }
public function testLogExceptionViaRenderer() { \Logger::configure(array('appenders' => array('echo' => array('class' => '\\LoggerAppenderEcho')), 'rootLogger' => array('level' => 'ERROR', 'appenders' => array('echo')), 'renderers' => array('Exception' => array('renderedClass' => 'AbacaphiliacTest\\PsrLog4Php\\FooBar', 'renderingClass' => 'AbacaphiliacTest\\PsrLog4Php\\FooBarRenderer'))), new \LoggerConfiguratorDefault()); $logger = \Logger::getLogger(__METHOD__); $sut = new LoggerWrapper($logger); ob_start(); $sut->error(new FooBar('FizzBuzz')); $actual = ob_get_clean(); self::assertEquals("ERROR - FizzBuzz\n", $actual); }
public function testAppendStderr() { $this->config['appenders']['default']['params']['target'] = 'stderr'; Logger::configure($this->config); $log = Logger::getRootLogger(); $expected = LoggerAppenderConsole::STDERR; $actual = $log->getAppender('default')->getTarget(); $this->assertSame($expected, $actual); $log->info("hello"); }
/** * * Bootstrap Logger * @return Logger */ protected function _initLog() { $options = $this->getOptions(); Logger::configure($options['log4php']['config']); define('LOGGER', 'default'); $log = Logger::getLogger('pinchshopper'); $log->debug("start"); Zend_Registry::set('logger', $log); return $log; }
/** * You can use this method if you want specific customizations to the log. * Otherwise you can instantiate this class and use the trace, warn, info, etc methods * * @param string $logName * @return \Logger */ public static function getLogger($logName = 'default') { $filename = new LogConfigFilenameProcessor('log4php'); if (!$filename->Exists()) { throw new NotFoundException('Log4php config file not found.'); } else { \Logger::configure($filename->FullQualifiedNameAndPath()); } return \Logger::getLogger($logName); }
public static function init() { if (self::$_INITIALIZED === FALSE) { $anyemConfigReader = new AnyemConfigReaderImpl(__DIR__ . '/../config/anyem_config.properties'); self::$_DEFAULT_MAX_ATTEMPT = $anyemConfigReader->readConfig(self::DEFAULT_MAX_ATTEMPT); self::$_DEFAULT_DELAY_ATTEMPT = $anyemConfigReader->readConfig(self::DEFAULT_DELAY_ATTEMPT); Logger::configure(__DIR__ . '/../config/log4php/config.xml'); self::$_LOG = Logger::getLogger(__CLASS__); self::$_INITIALIZED = TRUE; } }
public static function isSupported() { @(include_once 'log4php/Logger.php'); if (class_exists('Logger')) { if (!method_exists('Logger', 'configure')) { return false; } Logger::configure(LOG4PHP_CONFIGURATION); return true; } return false; }
public function testConfigure() { Logger::configure('configurators/test1.php', 'LoggerConfiguratorPhp'); $root = Logger::getRootLogger(); self::assertEquals(LoggerLevel::getLevelWarn(), $root->getLevel()); $appender = $root->getAppender("default"); self::assertTrue($appender instanceof LoggerAppenderEcho); $layout = $appender->getLayout(); self::assertTrue($layout instanceof LoggerLayoutSimple); $logger = Logger::getLogger('mylogger'); self::assertEquals(LoggerLevel::getLevelInfo(), $logger->getLevel()); }
public function testConfigureWithEmptyIniFile() { $catchedException = null; try { Logger::configure('configurators/test2.properties'); Logger::initialize(); self::assertTrue(false); } catch (LoggerException $e) { $catchedException = $e; } self::assertNotNull($catchedException); }
public static function scrie($mesaj, $averitzare = false) { Logger::configure('logger/config.xml'); $logger = Logger::getLogger("Foo"); if ($averitzare) { $logger->warn($mesaj); } else { $logger->info($mesaj); } // $logger->info("This is an informational message."); // $logger->warn("I'm not feeling so good..."); }
/** * init. * * @param String $class 呼び出し元クラス名 */ public function __construct($class = __CLASS__) { if (is_null($this->logger)) { $_file = __DIR__ . '/log4php.xml'; if (!is_file($_file)) { throw new RuntimeException('NotFound:log4php.xml'); } \Logger::configure($_file); $this->logger = \Logger::getLogger($class); } $this->logger->info('---------- ログ開始 -----'); }
static final function transLogger($transLogger, $transanctionInfo) { try { $timestamp = date('Y-m-d') . 'T' . date('H:i:s') . 'Z'; \Logger::configure(NULL, new WebLogConfigurator()); $log = \Logger::getLogger($transLogger); $log->info('[' . $timestamp . '] ' . $transanctionInfo); return true; } catch (\Exception $ex) { throw $ex; } }