nipyapi icon indicating copy to clipboard operation
nipyapi copied to clipboard

Unable to log using standard logging library.

Open rajarshnaidu opened this issue 5 years ago • 2 comments

  • Nipyapi version: 0.14.3
  • NiFi version: 1.9.0
  • NiFi-Registry version:
  • Python version: 3.6.3
  • Operating System: RHEL 7.7

Description

I'm trying to log into file using logging (package). But if i import nipyapi, it's not letting me log into a file.

What I Did

import nipyapi import logging logging.basicConfig(filename="/tmp/execution.log",level=logging.INFO,format='%(asctime)s:%(levelname)s:%(message)s') logging.info('Hello')

This doesn't log anything into /tmp/execution.log.

Urgency

All my scripts (monitoring, feed automation) are currently without any logging and it's hard to keep track of any failures or exceptions in scripts.

rajarshnaidu avatar Jun 01 '20 20:06 rajarshnaidu

Hey @Chaffelson I’d like you to know if there’s something wrong with the way I’m trying or if this is being tracked already? Thanks in advance.

rajarshnaidu avatar Jun 05 '20 22:06 rajarshnaidu

You'll want to look in nipyapi.nifi.configuration, nipyapi.registry.configuration, and the root nipyapi.config. Each defines the logging handlers associated, though with the root one it just does a basic config by default.

Probably what you want to do is access the nifi and registry loggers, and set the root nipyapi logger up by ovveriding these config paramters.

As it stands today the package logging setup isn't great by default, so I'll happily take suggestions on improvement.

Chaffelson avatar Jun 21 '20 13:06 Chaffelson