[Tutor] How to change default path output of 'logging'?
Dave Angel
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,
logging.basicConfig(filename="F:/data/logging_info/bumpr.log",
level=logging.INFO)
>
> 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
__file__
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.
--
DaveA
More information about the Tutor
mailing list