[Tutor] How to change default path output of 'logging'?
zachary.ware+pytut at gmail.com
Mon Dec 22 16:20:21 CET 2014
On Monday, December 22, 2014, Juan Christian <juan0christian at gmail.com
> I have a 'logging' on my code using:
> import logging
> < ... >
> logging.basicConfig(filename="bumpr.log", level=logging.INFO)
> < ... >
> The thing is that the default location of this output when running via
> Windows Task Scheduler is 'C:/Windows/System32'.
> Is there a way to change the location of the output of this module? I want
> it to output where my 'main.py' is.
That location is not a function of logging, it's a function of running via
Windows Task Scheduler, which apparently starts the program with a current
directory of C:\Windows\System32. The solution is to give logging an
absolute path for the output file (which you can base of off __file__,
something like """os.path.join(os.path.dirname(__file__), "bumpr.log")""") .
Hope this helps,
Sent from Gmail Mobile
More information about the Tutor