Logging from different python scripts to different output files

James McMahon jsmcmahon3 at gmail.com
Mon Mar 27 17:34:59 EDT 2017


I'm struggling with Python logging. Have tried to apply several examples I
have found in the open source literature, but can't get it to work. What I
need to do is this: I have two python scripts, a.py and b.py. Each is
called by NiFi ExecuteScript processor repeatedly against many incoming
flowfiles. In every case I need to output log messages to two distinct and
different log files. My scripts run in the same Python interpreter, which
as i understand it means they rely on the same root level logger. I have
tried establishing non-root loggers for each, and associating distinct file
handles for each to those loggers.

My output still appears in multiple log files, and appears to be repeating
in increasing numbers each time I try a test run (first test, output line
appeared in log once. second test, twice. third test, three times, etc). Is
there an example that anyone knows of that demonstrates how two
concurrently running python scripts within the same interpreter can direct
output to two distinct log files? Thanks in advance for any help.


More information about the Python-list mailing list