Class Logger

Description

This is the central class in the log4php package. All logging operations are done through this class.

The main logging methods are:

Located in /log4php/Logger.php (line 42)


	
			
Direct descendents
Class Description
LoggerRoot The root logger.
Method Summary
static boolean clear ()
static void configure ([string|array $configuration = null], [string|LoggerConfigurator $configurator = null])
static boolean exists (string $name)
static array getCurrentLoggers ()
static Logger getLogger (string $name)
static void resetConfiguration ()
static void shutdown ()
Logger __construct (string $name)
void addAppender (LoggerAppender $appender)
void assertLog ([bool $assertion = true], [string $msg = ''])
void debug (mixed $message, [Exception $throwable = null])
void error (mixed $message, [Exception $throwable = null])
void fatal (mixed $message, [Exception $throwable = null])
void forcedLog (string $fqcn, Exception $throwable, LoggerLevel $level, mixed $message)
boolean getAdditivity ()
array getAllAppenders ()
string getName ()
void info (mixed $message, [Exception $throwable = null])
boolean isAttached (LoggerAppender $appender)
boolean isDebugEnabled ()
boolean isEnabledFor (LoggerLevel $level)
boolean isErrorEnabled ()
boolean isFatalEnabled ()
boolean isInfoEnabled ()
boolean isTraceEnabled ()
boolean isWarnEnabled ()
void log (LoggerLevel $level, mixed $message, [Exception $throwable = null])
void logEvent (LoggerLoggingEvent $event)
void removeAppender (mixed $appender)
void setAdditivity (boolean $additive)
void setLevel ([LoggerLevel $level = null])
void setParent (Logger $logger)
void trace (mixed $message, [Exception $throwable = null])
void warn (mixed $message, [Exception $throwable = null])
Methods
static method clear (line 484)

Clears all Logger definitions from the logger hierarchy.

  • access: public
static boolean clear ()
static method configure (line 540)

Configures log4php.

This method needs to be called before the first logging event has occured. If this method is not called before then the default configuration will be used.

  • access: public
static void configure ([string|array $configuration = null], [string|LoggerConfigurator $configurator = null])
  • string|array $configuration: Either a path to the configuration file, or a configuration array.
  • string|LoggerConfigurator $configurator: A custom configurator class: either a class name (string), or an object which implements the LoggerConfigurator interface. If left empty, the default configurator implementation will be used.
static method exists (line 512)

check if a given logger exists.

  • access: public
static boolean exists (string $name)
  • string $name: logger name
static method getCurrentLoggers (line 521)

Returns an array this whole Logger instances.

static array getCurrentLoggers ()
static method getHierarchy (line 449)

Returns the hierarchy used by this Logger.

Caution: do not use this hierarchy unless you have called initialize(). To get Loggers, use the Logger::getLogger and Logger::getRootLogger methods instead of operating on on the hierarchy directly.

  • access: public
static LoggerHierarchy getHierarchy ()
static method getLogger (line 462)

Returns a Logger by name. If it does not exist, it will be created.

  • access: public
static Logger getLogger (string $name)
  • string $name: The logger name
static method getRootLogger (line 473)

Returns the Root Logger.

  • access: public
static LoggerRoot getRootLogger ()
static method resetConfiguration (line 491)

Destroy configurations for logger definitions

  • access: public
static void resetConfiguration ()
static method shutdown (line 502)

Safely close all appenders.

  • deprecated: This is no longer necessary due the appenders shutdown via destructors.
  • access: public
static void shutdown ()
Constructor __construct (line 73)

Constructor.

  • access: public
Logger __construct (string $name)
  • string $name: Name of the logger.

Redefined in descendants as:
addAppender (line 321)

Adds a new appender to the Logger.

  • access: public
void addAppender (LoggerAppender $appender)
assertLog (line 211)

If assertion parameter evaluates as false, then logs the message using the ERROR level.

  • access: public
void assertLog ([bool $assertion = true], [string $msg = ''])
  • bool $assertion
  • string $msg: message to log
callAppenders (line 245)

Forwards the given logging event to all linked appenders.

  • access: public
void callAppenders (LoggerLoggingEvent $event)
debug (line 115)

Log a message object with the DEBUG level.

  • access: public
void debug (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.
error (line 148)

Log a message object with the ERROR level.

  • access: public
void error (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.
fatal (line 159)

Log a message object with the FATAL level.

  • access: public
void fatal (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.
forcedLog (line 231)

This method creates a new logging event and logs the event without further checks.

It should not be called directly. Use trace(), debug(), info(), warn(), error() and fatal() wrappers.

  • access: public
void forcedLog (string $fqcn, Exception $throwable, LoggerLevel $level, mixed $message)
  • string $fqcn: Fully qualified class name of the Logger
  • Exception $throwable: Optional throwable information to include in the logging event.
  • LoggerLevel $level: log level
  • mixed $message: message to log
getAdditivity (line 375)

Returns the additivity flag.

  • access: public
boolean getAdditivity ()
getAllAppenders (line 351)

Returns the appenders linked to this logger as an array.

  • return: collection of appender names
  • access: public
array getAllAppenders ()
getAppender (line 359)

Returns a linked appender by name.

  • access: public
LoggerAppender getAppender ( $name)
  • $name
getEffectiveLevel (line 384)

Starting from this Logger, search the Logger hierarchy for a non-null level and return it.

LoggerLevel getEffectiveLevel ()

Redefined in descendants as:
getLevel (line 396)

Get the assigned Logger level.

  • return: The assigned level or null if none is assigned.
  • access: public
LoggerLevel getLevel ()
getName (line 81)

Returns the logger name.

  • access: public
string getName ()
getParent (line 89)

Returns the parent Logger. Can be null if this is the root logger.

  • access: public
Logger getParent ()
info (line 126)

Log a message object with the INFO Level.

  • access: public
void info (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.
isAttached (line 418)

Checks whether an appender is attached to this logger instance.

  • access: public
boolean isAttached (LoggerAppender $appender)
isDebugEnabled (line 277)

Check whether this Logger is enabled for the DEBUG Level.

  • access: public
boolean isDebugEnabled ()
isEnabledFor (line 261)

Check whether this Logger is enabled for a given Level passed as parameter.

  • access: public
boolean isEnabledFor (LoggerLevel $level)
isErrorEnabled (line 301)

Check whether this Logger is enabled for the ERROR Level.

  • access: public
boolean isErrorEnabled ()
isFatalEnabled (line 309)

Check whether this Logger is enabled for the FATAL Level.

  • access: public
boolean isFatalEnabled ()
isInfoEnabled (line 285)

Check whether this Logger is enabled for the INFO Level.

  • access: public
boolean isInfoEnabled ()
isTraceEnabled (line 269)

Check whether this Logger is enabled for the TRACE Level.

  • access: public
boolean isTraceEnabled ()
isWarnEnabled (line 293)

Check whether this Logger is enabled for the WARN Level.

  • access: public
boolean isWarnEnabled ()
log (line 171)

Log a message using the provided logging level.

  • access: public
void log (LoggerLevel $level, mixed $message, [Exception $throwable = null])
  • LoggerLevel $level: The logging level.
  • mixed $message: Message to log.
  • Exception $throwable: Optional throwable information to include in the logging event.
logEvent (line 193)

Logs an already prepared logging event object.

  • access: public
void logEvent (LoggerLoggingEvent $event)
removeAllAppenders (line 327)

Removes all appenders from the Logger.

  • access: public
void removeAllAppenders ()
removeAppender (line 337)

Remove the appender passed as parameter form the Logger.

  • access: public
void removeAppender (mixed $appender)
setAdditivity (line 367)

Sets the additivity flag.

  • access: public
void setAdditivity (boolean $additive)
  • boolean $additive
setLevel (line 408)

Set the Logger level.

Use LoggerLevel::getLevelXXX() methods to get a LoggerLevel object, e.g.

  • access: public
void setLevel ([LoggerLevel $level = null])
  • LoggerLevel $level: The level to set, or NULL to clear the logger level.

Redefined in descendants as:
  • LoggerRoot::setLevel() : Override level setter to prevent setting the root logger's level to null. Root logger must always have a level.
setParent (line 426)

Sets the parent logger.

  • access: public
void setParent (Logger $logger)

Redefined in descendants as:
trace (line 104)

Log a message object with the TRACE level.

  • access: public
void trace (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.
warn (line 137)

Log a message with the WARN level.

  • access: public
void warn (mixed $message, [Exception $throwable = null])
  • mixed $message: message
  • Exception $throwable: Optional throwable information to include in the logging event.

Documentation generated on Tue, 12 Mar 2024 14:04:50 +0900 by phpDocumentor 1.4.4