Skip to content

Instantly share code, notes, and snippets.

@dims

dims/app.py

Created Mar 17, 2015
Embed
What would you like to do?
oslo.config + oslo.log sample
import sys
from oslo.config import cfg
from oslo_log import log as oslo_logging
CONF = cfg.CONF
CONF.register_opt(cfg.StrOpt('NODE_NAME'), cfg.OptGroup('HA'))
def main():
oslo_logging.register_options(CONF)
CONF(sys.argv[1:], default_config_files=['app.conf'])
oslo_logging.setup(CONF, 'xyz')
LOG = oslo_logging.getLogger('')
try:
raise Exception('hello')
except:
LOG.error('got exception')
if __name__ == '__main__':
main()
#/etc/my.conf
[DEFAULT]
###########
# Logging #
###########
# syslog server configuration (default port(UDP): 514)
# NOTE: Following logging configuration can be left as is for logs to come on UI
syslog_host=127.0.0.1
syslog_port=514
# log facility
log_facility=LOG_LOCAL3
[HA]
NODE_NAME=NODE1
DIR_STR=/opt
[OPENSTACK]
HA_VIRTUAL_IP=192.168.0.26
@ruiruige

This comment has been minimized.

Copy link

@ruiruige ruiruige commented Nov 17, 2017

Really thanks, this helps a lot to me!

@jesusmoralesaguiar

This comment has been minimized.

Copy link

@jesusmoralesaguiar jesusmoralesaguiar commented May 31, 2018

Very nice example!!! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment