Logger
Logger
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Methods summary
Modifier and Type | Method |
---|---|
public | __construct ( string name ) |
public string | getName ( ) |
public Logger | getParent ( ) |
public | trace ( unknown message , unknown throwable = null ) |
public | debug ( mixed message , Exception throwable = null ) |
public | info ( mixed message , Exception throwable = null ) |
public | warn ( mixed message , Exception throwable = null ) |
public | error ( mixed message , Exception throwable = null ) |
public | fatal ( mixed message , Exception throwable = null ) |
public | log ( LoggerLevel level , mixed message , Exception throwable = null ) |
public | logEvent ( LoggingEvent event ) |
public | assertLog ( bool assertion = true , string msg = '' ) |
public | forcedLog ( string fqcn , Exception throwable , LoggerLevel level , mixed message ) |
public | callAppenders ( LoggingEvent event ) |
public | isEnabledFor ( LoggerLevel level ) |
public boolean | isTraceEnabled ( ) |
public boolean | isDebugEnabled ( ) |
public boolean | isInfoEnabled ( ) |
public boolean | isWarnEnabled ( ) |
public boolean | isErrorEnabled ( ) |
public boolean | isFatalEnabled ( ) |
public | addAppender ( unknown appender ) |
public | removeAllAppenders ( ) |
public | removeAppender ( mixed appender ) |
public array | getAllAppenders ( ) |
public LoggerAppender | getAppender ( unknown name ) |
public | setAdditivity ( boolean additive ) |
public boolean | getAdditivity ( ) |
public LoggerLevel | getEffectiveLevel ( ) |
public LoggerLevel | getLevel ( ) |
public | setLevel ( LoggerLevel level = null ) |
public boolean | isAttached ( LoggerAppender appender ) |
public | setParent ( Logger logger ) |
public static LoggerHierarchy | getHierarchy ( ) |
public static Logger | getLogger ( string name ) |
public static LoggerRoot | getRootLogger ( ) |
public static boolean | clear ( ) |
public static | resetConfiguration ( ) |
public static | shutdown ( ) |
public static boolean | exists ( string name ) |
public static array | getCurrentLoggers ( ) |
public static | configure ( string|array configuration = null , LoggerConfigurator configurator = null ) |
Methods in detail
-
__construct
public __construct ( string name )Constructor.param
string name Name of the logger. -
getName
string public getName ( )Returns the logger name.return
string -
getParent
Logger public getParent ( )Returns the parent Logger. Can be null if this is the root logger.return
-
trace
public trace ( unknown message , unknown throwable = null ) -
debug
public debug ( mixed message , Exception throwable = null )Log a message object with the DEBUG level.param
mixed message messageException throwable Optional throwable information to include in the logging event. -
info
public info ( mixed message , Exception throwable = null )Log a message object with the INFO Level.param
mixed message messageException throwable Optional throwable information to include in the logging event. -
warn
public warn ( mixed message , Exception throwable = null )Log a message with the WARN level.param
mixed message messageException throwable Optional throwable information to include in the logging event. -
error
public error ( mixed message , Exception throwable = null )Log a message object with the ERROR level.param
mixed message messageException throwable Optional throwable information to include in the logging event. -
fatal
public fatal ( mixed message , Exception throwable = null )Log a message object with the FATAL level.param
mixed message messageException throwable Optional throwable information to include in the logging event. -
log
Log a message using the provided logging level.param
LoggerLevel The logging level.mixed message Message to log.Exception throwable Optional throwable information to include in the logging event. -
logEvent
Logs an already prepared logging event object.param
-
assertLog
public assertLog ( bool assertion = true , string msg = '' )If assertion parameter evaluates as false, then logs the message using the ERROR level.param
bool assertionstring msg message to log -
forcedLog
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.param
string fqcn Fully qualified class name of the LoggerException throwable Optional throwable information to include in the logging event.LoggerLevel log levelmixed message message to log -
callAppenders
Forwards the given logging event to all linked appenders.param
-
isEnabledFor
public isEnabledFor ( LoggerLevel level ) -
isTraceEnabled
boolean public isTraceEnabled ( )Check whether this Logger is enabled for the TRACE Level.return
boolean -
isDebugEnabled
boolean public isDebugEnabled ( )Check whether this Logger is enabled for the DEBUG Level.return
boolean -
isInfoEnabled
boolean public isInfoEnabled ( )Check whether this Logger is enabled for the INFO Level.return
boolean -
isWarnEnabled
boolean public isWarnEnabled ( )Check whether this Logger is enabled for the WARN Level.return
boolean -
isErrorEnabled
boolean public isErrorEnabled ( )Check whether this Logger is enabled for the ERROR Level.return
boolean -
isFatalEnabled
boolean public isFatalEnabled ( )Check whether this Logger is enabled for the FATAL Level.return
boolean -
addAppender
public addAppender ( unknown appender ) -
removeAllAppenders
public removeAllAppenders ( ) -
removeAppender
public removeAppender ( mixed appender )Remove the appender passed as parameter form the Logger.param
mixed appender an appender name or a LoggerAppender instance. -
getAllAppenders
array public getAllAppenders ( )Returns the appenders linked to this logger as an array.return
array -
getAppender
Returns a linked appender by name.return
-
setAdditivity
public setAdditivity ( boolean additive )Sets the additivity flag.param
boolean additive -
getAdditivity
boolean public getAdditivity ( )Returns the additivity flag.return
boolean -
getEffectiveLevel
LoggerLevel public getEffectiveLevel ( )Starting from this Logger, search the Logger hierarchy for a non-null level and return it. -
getLevel
LoggerLevel public getLevel ( )Get the assigned Logger level.return
-
setLevel
Set the Logger level. Use \n2n\log4php\LoggerLevel::getLevelXXX() methods to get a \n2n\log4php\LoggerLevel object, e.g.$logger->setLevel(\n2n\log4php\LoggerLevel::getLevelInfo());
param
LoggerLevel The level to set, or NULL to clear the logger level. -
isAttached
Checks whether an appender is attached to this logger instance. -
setParent
Sets the parent logger.param
-
getHierarchy
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.return
-
getLogger
Returns a Logger by name. If it does not exist, it will be created. -
getRootLogger
Returns the Root Logger.return
-
clear
boolean public static clear ( )Clears all Logger definitions from the logger hierarchy.return
boolean -
resetConfiguration
public static resetConfiguration ( )Destroy configurations for logger definitions -
shutdown
public static shutdown ( )Safely close all appenders.deprecated
deprecated -
exists
boolean public static exists ( string name )check if a given logger exists.param
string name logger namereturn
boolean -
getCurrentLoggers
array public static getCurrentLoggers ( )Returns an array this whole Logger instances. -
configure
public static configure ( string|array configuration = null , LoggerConfigurator configurator = null )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.param
string|array configuration Either a path to the configuration file, or a configuration array.LoggerConfigurator configurator A custom configurator class: either a class name (string), or an object which implements the \n2n\log4php\LoggerConfigurator interface. If left empty, the default configurator implementation will be used.