How to configure the Logging for titanfe¶
The titan FlowEngine utilizes Python’s builtin Logging
module.
It can be configured via a configuration file, which is located in ./titanfe/logutils/log_config.yml
The following will provide a brief overview, a more detailed explanation can be found in the Python Documentation:
Loggers¶
The loggers section contains two Loggers, that can be configured separately:
titanfe
titanfe.bricks
The “titanfe” logger will capture any titanfe internal log messages, whereas the “titanfe.bricks” logger will capture any logging from within a brick.
For each logger you can set a log level and one or more specific handlers:
loggers:
titanfe:
level: INFO
handlers: [console]
The above would capture all logging on info level and above (warning) and output it to the console.
Furthermore, there is a global “root”-Logger, that captures LogRecords from all other loggers
unless they are explicitly set to propagate: False
.
If enabled the root logger allows you to capture logs from Python internals like the debug
output of the asyncio
package.
To enable the root logger set:
root:
level: DEBUG
handlers:
- console
Handlers¶
The handlers section allows specifying different handlers. Note: An instance of each configured handler gets created on initialization of the Python logging module, regardless of if it gets assigned to any logger or not.
The handlers section allows to specify different handlers. Note: An instance for each configured handler will be created, regardless if it is assigned to any logger or not.
A handler could for example output to the console, write to a file or stream the log records to a remote system. See logging.handlers for the builtin options.
Each handler has the following options:
handlers:
console:
class: logging.StreamHandler # the python class to instantiate
level: INFO # minimum log level for this handler
formatter: default # a formatter
filters: [hostname] # additional filters for the formatter to use
stream: ext://sys.stdout # parameters for the class to instantiate, will be passed in as keywords
Formatter¶
A formatter is used to specify how the log message is to be build up.
Formatter:
default:
format: "%(asctime)s %(hostname)s (%(process)5d|%(thread)-5d) %(name)s %(levelname)-8s %(message)s"
above renders to 2019-09-25 14:06:29,961 COMPUTER (15032|3448 ) titanfe.bricks.generator INFO Finished generating
see Logrecord Attributes for the available options.