Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1222236

Summary: logging file is not created when using from ovirt.node.utils.fs import Config
Product: [Retired] oVirt Reporter: Douglas Schilling Landgraf <dougsland>
Component: ovirt-nodeAssignee: Douglas Schilling Landgraf <dougsland>
Status: CLOSED NOTABUG QA Contact: bugs <bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.6CC: ecohen, gklein, lsurette, mgoldboi, ovirt-bugs, rbalakri, yeylon
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-16 21:46:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Douglas Schilling Landgraf 2015-05-16 19:21:05 UTC
Description of problem:

Working in a tool https://gerrit.ovirt.org/#/c/40966/ and noticed that if I use from ovirt.node.utils.fs import Config in the top of source, the logging file expected to be created by the tool is not created, the workaround was to unload the logging module and reload it.

Comment 1 Douglas Schilling Landgraf 2015-05-16 21:46:06 UTC
I was not setting the logging handlers, so when loading the ovirt node modules which set it, the program was inheriting it too. For reference only, the below code, handle the logging as expected.

   def __set_logger(self):
        """
        The logging settings
        Saving log in: /var/log/vdsm/register.log
        """
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)
        logger.propagate = False

        fh = logging.FileHandler("/var/log/vdsm/register.log")
        fh.setLevel(logging.DEBUG)

        ch = logging.StreamHandler(stream=sys.stdout)
        ch.setLevel(logging.ERROR)

        de_fmt = logging.Formatter("%(asctime)s %(message)s",
                                   "%m/%d/%Y %I:%M:%S %p")

        ih = logging.StreamHandler(stream=sys.stdout)
        ih.setLevel(logging.INFO)

        i_fmt = logging.Formatter("%(message)s",
                                  "%m/%d/%Y %I:%M:%S %p")

        fh.setFormatter(de_fmt)
        ch.setFormatter(de_fmt)
        ih.setFormatter(i_fmt)

        logger.addHandler(fh)
        logger.addHandler(ch)
        logger.addHandler(ih)

        logging.captureWarnings(True)

        return logger