nipyapi
nipyapi copied to clipboard
Unable to log using standard logging library.
- 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.
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.
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.