Loggers
There are two ways of logging messages from a Python context:
• directly through the Root Logger, or
• through a Custom Logger.
Root Logger
The following example logs a message of each supported type through Python's root logger:
import logging logging.info("This is an informational message.") logging.warning("This is a warning message.") logging.error("This is an error message.") logging.critical("This is a fatal error message.") logging.debug("This is a debugging message.")
Custom Logger
Instead of using the root logger, you can create a custom logger object. The following example creates a custom logger and generates a message of each level using that logger:
import logging log = logging.getLogger("myLogger") log.info("This is an informational message.") log.warning("This is a warning message.") log.error("This is an error message.") log.critical("This is a fatal error message.") log.debug("This is a debugging message.")
Note: The message level display option in the Messages tab is independent of the level of message actually generated. For example, if the Messages tab is set to show debug messages, debug messages are only actually displayed if the level of message generated is also set to include debug. Refer to The Message Center for more information on how to set the level of message that is generated.
log4cplus.appender.KatanaConsoleOutput=log4cplus::ConsoleAppender log4cplus.appender.KatanaConsoleOutput.layout=log4cplus::PatternLayout log4cplus.appender.KatanaConsoleOutput.layout.ConversionPattern=[%p%c]: %m%n
log4cplus.appender.KatanaConsoleOutput.layout.ConversionPattern=[%p %c]: %m%n
log4cplus.appender.KatanaConsoleOutput.layout.ConversionPattern=[%p %c %d]: %m%n