0

Not sure why my logger isn't logging anything. My log file is generated by there is no content in the log file.

setup logger:

    log = logging.getLogger(me)
    dt = datetime.datetime.utcnow()
    logfile = "qe/logs/" + args.runtag + "_{}_{}_{}".format(dt.month, dt.day, dt.year) + "_cron.log"
    if isinstance(logfile,str):
        if os.path.exists(logfile):
            os.remove(logfile)
        log.addHandler(logging.FileHandler(logfile))
    console = logging.StreamHandler(sys.stderr); console.setLevel(logging.WARNING); log.addHandler(console)

usage:

    log.info("{0}: START: {1}".format(me, datetime.datetime.now().ctime()))
    log.info("RUNTAG: {}".format(args.runtag))
    TestWildCardEvents(log, test_objs, args.runtag).runTest()

TestWildCardEvents:

class TestWildCardEvents():
    def __init__(self, log, test_objs, runtag):
        self.log = log
        self.test_objs = test_objs
        self.runtag = runtag
        self.e2e_order = ['post', 'hdfs', 'hive']

    def runTest(self):
        self.log.info("test")
        for phase in self.e2e_order:
            phase_obj = jpath_get(self.test_objs, phase)
            if phase_obj is not None:
                print("test")

my log is created but there is no content within the file.

Liondancer
  • 15,721
  • 51
  • 149
  • 255

0 Answers0