Python logging.config.fileConfig() Examples
The following are 6
code examples of logging.config.fileConfig().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
logging.config
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: configuration_manager.py From panoptes with Apache License 2.0 | 6 votes |
def _setup_logging(self, config): log_config_file = config[u'log'][u'config_file'] self._logger.info(u'Logging configuration file: ' + log_config_file) try: logging.config.fileConfig(log_config_file) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, limit=2, file=sys.stderr) raise PanoptesConfigurationError( u'Could not instantiate logger with logging configuration provided in file "%s": (%s) %s' % ( log_config_file, exc_type, exc_value)) # Create a filter to rate limit logs so that a misconfiguration or failure does not make the disk I/O go # beserk or fill up the disk space. We do this in code instead if configuration for two reasons: # - It enforces a filter on every handler, so no chance of messing them up in configuration # - We use fileConfig (nof dictConfig) to setup our logging and fileConfig does not support filter configuration throttle = RateLimitingFilter(rate=config[u'log'][u'rate'], per=config[u'log'][u'per'], burst=config[u'log'][u'burst']) # Apply the filter to all handlers. Note that this would be a shared filter across ALL logs generated by this # process and thus the rate/burst should be set appropriately high for handler in logging._handlerList: # _handlerList is a list of weakrefs, so the object returned has to be dereferenced handler().addFilter(throttle)
Example #2
Source File: log_config.py From storj-python-sdk with MIT License | 6 votes |
def load_configuration(config_file=DEFAULT_CONFIG_FILE): """ Loads logging configuration from the given configuration file. :param config_file: the configuration file (default=/etc/package/logging.conf) :type config_file: str """ if not os.path.exists(config_file) or not os.path.isfile(config_file): msg = '%s configuration file does not exist!', config_file logging.getLogger(__name__).error(msg) raise ValueError(msg) try: config.fileConfig(config_file, disable_existing_loggers=False) logging.getLogger(__name__).info( '%s configuration file was loaded.', config_file) except Exception as e: logging.getLogger(__name__).error( 'Failed to load configuration from %s!', config_file) logging.getLogger(__name__).debug(str(e), exc_info=True) raise e
Example #3
Source File: serve.py From pulsar with Apache License 2.0 | 5 votes |
def logging_file_config(self, config_file): """ Setup logging via the logging module's fileConfig function with the specified ``config_file``, if applicable. ConfigParser defaults are specified for the special ``__file__`` and ``here`` variables, similar to PasteDeploy config loading. """ parser = ConfigParser.ConfigParser() parser.read([config_file]) if parser.has_section('loggers'): config_file = os.path.abspath(config_file) fileConfig(config_file, dict(__file__=config_file, here=os.path.dirname(config_file)))
Example #4
Source File: Logging.py From grease with MIT License | 5 votes |
def ProvisionLoggers(self): """Loads Log Handler & Config Returns: None: Simple loader, Nothing needed """ if self._conf.get('Logging', 'ConfigurationFile'): if os.path.isfile(self._conf.get('Logging', 'ConfigurationFile')): config.fileConfig(self._conf.get('Logging', 'ConfigurationFile')) self._logger = logging.getLogger('GREASE') else: self.DefaultLogger() else: self.DefaultLogger()
Example #5
Source File: logs.py From kytos with MIT License | 5 votes |
def _use_config_file(cls, config_file): """Use parsed logging configuration.""" try: config.fileConfig(cls._PARSER, disable_existing_loggers=False) LOG.info('Logging config file "%s" loaded successfully.', config_file) except OSError: cls._catch_config_file_exception(config_file)
Example #6
Source File: __init__.py From EasyStorj with MIT License | 5 votes |
def setup_logging(): """Reads the Storj GUI logging configuration from logging.conf. If the file does not exist it will load a default configuration. Mac OS X (POSIX): ~/.storj-gui Unix (POSIX): ~/.storj-gui Win XP (not roaming): ``C:\Documents and Settings\<user>\Application Data\storj-gui`` Win 7 (not roaming): ``C:\\Users\<user>\AppData\Local\storj-gui`` """ logging_conf = os.path.join( click.get_app_dir(APP_NAME, force_posix=True), 'logging.conf') if not os.path.exists(logging_conf) or not os.path.isfile(logging_conf): load_default_logging() logging.getLogger(__name__).warning('%s logging configuration file does not exist', logging_conf) return try: config.fileConfig(logging_conf, disable_existing_loggers=False) logging.getLogger(__name__).info('%s configuration file was loaded.', logging_conf) except RuntimeError: load_default_logging() logging.getLogger(__name__).warning('failed to load configuration from %s', logging_conf) return logging.getLogger(__name__).info('using logging configuration from %s', logging_conf)