Skip to content

Configure logging

Loggers

The configuration of loggers is structured as a dictionary where the key is the name of the logger and the value is a dictionary containing configuration on how to setup the logger. Example: 'backend': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}

LogLevel

Attribute: loglevel - debug - info - warning - critical - exception

HandlerConf

Attribute: handlerConf Possibility to specify a separate handler for each logger. For structure see section under "Handler"

Handler

Attribute: handler Example: "handler": "default" Can be used instead of "handlerConf" and will use the corresponding handler from handler configuration

Handler

Structured as a dictionary of name and "handlerConf" Example: "default": {'handlerConf':{'logHandler':[{'target':'stderr'}]}}

Log to stdout

'logHandler':[{'target':'stdout'}]

Log to stderr

'logHandler':[{'target':'stderr'}]

Log to file

'logHandler':[{'target':'file', 'filePath': '/var/log/didmos/didmos2core.log'}]

Log to file with log rotate

'logHandler':[{'target':'rotate', 'filePath': '/var/log/didmos/didmos2core.log', 'maxBytes':200000, 'backupCount': 5}] maxBytes: Size of file when rotate (default: 200000) backupCount: Number of files to keep (default: 10)

Full Example

Separate handler for each logger

loggers : { 'django': {'loglevel': 'error', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'generator': {'loglevel': 'debug', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'tasks': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'backend': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'authentication': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'didmos2lib': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'ldapconnector': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'ldaplayer': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'rbac': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'permissions': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'validation': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'tenancy': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'csvparser': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'scimfilterparser': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'scimv2exception': {'loglevel': 'info', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'notification': {'loglevel': 'error', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'suggestion_helper': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'synchandler': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'pdpfunctioncontainer': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, 'ldapconnector.performance': {'loglevel': 'warning', 'handlerConf':{'logHandler':[{'target':'stderr'}]}}, }

One handler for all logger

handler : { 'default':{'logHandler':[{'target':'file', 'filePath': '/var/log/didmos/didmos2core.log'}]} } loggers : { 'django': {'loglevel': 'error', 'handler':'default'}, 'tasks': {'loglevel': 'info', 'handler':'default'}, 'backend': {'loglevel': 'debug', 'handler':'default'}, 'authentication': {'loglevel': 'info', 'handler':'default'}, 'didmos2lib': {'loglevel': 'info', 'handler':'default'}, 'ldapconnector': {'loglevel': 'debug', 'handler':'default'}, 'ldaplayer': {'loglevel': 'debug', 'handler':'default'}, 'rbac': {'loglevel': 'info', 'handler':'default'}, 'permissions': {'loglevel': 'info', 'handler':'default'}, 'validation': {'loglevel': 'info', 'handler':'default'}, 'tenancy': {'loglevel': 'info', 'handler':'default'}, 'notification': {'loglevel': 'error', 'handler':'default'}, 'scimv2exception': {'loglevel': 'info', 'handler':'default'}, 'customer': {'loglevel': 'debug', 'handler':'default'}, }