[Tutor] How to change default path output of 'logging'?
davea at davea.name
Mon Dec 22 16:34:59 CET 2014
On 12/22/2014 07:53 AM, Juan Christian wrote:
> 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'.
You want it in a different file, specify a different file. For example,
> Is there a way to change the location of the output of this module? I want
> it to output where my 'main.py' is.
No idea what part main.py plays to your code. If it's imported, then
you could use main.__file__ to get the full pathname to it. Then use
os.path.dirname() to get the directory. Then use os.path.join() to
combine that with "bumpr.log".
More likely, this is your script. So if you're trying to get the
filename from the script, you just use
And if that doesn't show up as an absolute path, use os.path.abspath. i
couldn't test that part, since I don't use Windows, and can't play with
the Windows Task Scheduler.
More information about the Tutor