Reputation: 35
I have .py script which starts java application from shell using os.system
. There are always a lot of WARNING messages after starting java apperas. I want just to write them in log file without printing them in console. I dont get how to catch them... Is it possible to do using logging lib?
Upvotes: 3
Views: 38
Reputation: 23815
something like the below
import subprocess
p = subprocess.Popen(["java", "<java args goes here>"], stdout=subprocess.PIPE)
out, err = p.communicate() # out || err will hold the data you are looking for - you can write them to python logger
Upvotes: 1