任何人都有一个想法,即如何在名为python.conf的配置文件中包括(orator.connection.queries)的配置,该文件将用于使用logging.config.fileConfig设置日志记录配置
这是我的配置文件(python.conf)
[handlers]
keys=HTTPSHandler,FileHandler,StreamHandler
[handler_HTTPSHandler]
class=loggly.handlers.HTTPSHandler
formatter=jsonFormat
args=('https://logs-01.loggly.com/inputs/<LOGGLY TOKEN>/tag/dev_log','POST')
[handler_FileHandler]
class=FileHandler
formatter=textFormat
args=('/var/www/html/python.log','a')
[handler_StreamHandler]
class=StreamHandler
level=DEBUG
formatter=textFormat
args=(sys.stdout,)
[formatters]
keys=jsonFormat,textFormat,dbtextFormat
[loggers]
keys=root,orator.connection.queries
[logger_root]
handlers=HTTPSHandler,FileHandler,StreamHandler
level=DEBUG
[logger_orator.connection.queries]
handlers=StreamHandler
level=DEBUG
[formatter_jsonFormat]
format={ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"}
datefmt=
[formatter_textFormat]
format=Logger Name = %(name)s
Date Time = %(asctime)s
File Name = %(filename)s
Log Record Creation Time = %(created)s
Function Name = %(funcName)s
Level No = %(levelno)s
Line No = %(lineno)s
Time = %(msecs)d
Level Name = %(levelname)s
Message = "%(message)s"
=======================================================================
[formatter_dbtextFormat]
format=It took %(elapsed_time)sms to execute the query %(query)s
我遇到以下错误:
Traceback (most recent call last):
File "module_test.py", line 225, in <module>
call_DataAnalyser = DataAnalyser()
File "module_test.py", line 35, in __init__
self.call_LogglyController = LogglyController(logger_name)
File "/var/www/html/integrations-python/core/loggly.py", line 10, in __init__
logging.config.fileConfig(os.environ['APP_PATH'] + 'core/python.conf')
File "/usr/lib/python2.7/logging/config.py", line 86, in fileConfig
_install_loggers(cp, handlers, disable_existing_loggers)
File "/usr/lib/python2.7/logging/config.py", line 228, in _install_loggers
qn = cp.get(sectname, "qualname")
File "/usr/lib/python2.7/ConfigParser.py", line 618, in get
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'qualname' in section: 'logger_orator.connection.queries'