Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Logging output to be redirected to a particular folder (http://www.velocityreviews.com/forums/t954248-logging-output-to-be-redirected-to-a-particular-folder.html)

anuradha.raghupathy2010@gmail.com 11-06-2012 11:28 AM

Logging output to be redirected to a particular folder
 
Hi,

Below is the python code that I have. I want to redirect the output to my C drive..myapp.log.

I am editing and creating scripts in IDLE and running it as a python shell or module.

Can you help?

import logging

def main():
logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)
logging.debug('started debug')
logging.info('info printing')
logging.warning('test warning')
logging.debug('debug again')
logging.error('Error')

if __name__ == '__main__':
main()

Peter Otten 11-06-2012 12:26 PM

Re: Logging output to be redirected to a particular folder
 
anuradha.raghupathy2010@gmail.com wrote:

> Hi,
>
> Below is the python code that I have. I want to redirect the output to my
> C drive..myapp.log.
>
> I am editing and creating scripts in IDLE and running it as a python shell
> or module.
>
> Can you help?
>
> import logging
>
> def main():
> logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)


Python is case-sensitive. Try:

logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)

> logging.debug('started debug')
> logging.info('info printing')
> logging.warning('test warning')
> logging.debug('debug again')
> logging.error('Error')
>
> if __name__ == '__main__':
> main()




Dennis Lee Bieber 11-06-2012 05:38 PM

Re: Logging output to be redirected to a particular folder
 
On Tue, 06 Nov 2012 13:26:11 +0100, Peter Otten <__peter__@web.de>
declaimed the following in gmane.comp.python.general:

> anuradha.raghupathy2010@gmail.com wrote:
>
> > Hi,
> >
> > Below is the python code that I have. I want to redirect the output to my
> > C drive..myapp.log.
> >
> > I am editing and creating scripts in IDLE and running it as a python shell
> > or module.
> >
> > Can you help?
> >
> > import logging
> >
> > def main():
> > logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)

>
> Python is case-sensitive. Try:
>
> logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)
>

The double forward slashes might also be confusing... At the least,
unneeded...

>>> import os.path
>>> print os.path.normpath("c://somefile.log")

c:\somefile.log
>>> print os.path.normpath("c:\\somefile.log")

c:\somefile.log
>>> print os.path.normpath("c:\\tryfile.log")

c:\tryfile.log
>>> print os.path.normpath("c:\tryfile.log")

c: ryfile.log
>>> print os.path.normpath("c:/tryfile.log")

c:\tryfile.log
>>>


Doubling back-slashes is needed to avoid the problem of literal
escapes corrupting the intent...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/


Prasad, Ramit 11-06-2012 05:58 PM

RE: Logging output to be redirected to a particular folder
 
Dennis Lee Bieber wrote:

>
> On Tue, 06 Nov 2012 13:26:11 +0100,Peter Otten <__peter__@web.de>
> declaimed the following in gmane.comp.python.general:
>

> > anuradha.raghupathy2010@gmail.com wrote:

[snip]

> > > def main():
> > > logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)

> >
> > Python is case-sensitive. Try:
> >
> > logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)
> >

> The double forward slashes might also be confusing... At the least,
> unneeded...
>

> >>> import os.path
> >>> print os.path.normpath("c://somefile.log")

> c:\somefile.log

> >>> print os.path.normpath("c:\\somefile.log")

> c:\somefile.log

> >>> print os.path.normpath("c:\\tryfile.log")

> c:\tryfile.log

> >>> print os.path.normpath("c:\tryfile.log")

> c: ryfile.log

> >>> print os.path.normpath("c:/tryfile.log")

> c:\tryfile.log

> >>>

>
> Doubling back-slashes is needed to avoid the problem of literal
> escapes corrupting the intent...


Or use the raw literal form r"c:\tryfile.log". I know several
people that prefer to use forward slashes as it works in both
Windows and *nix.


~Ramit


This email is confidential and subject to important disclaimersand
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.

anuradha.raghupathy2010@gmail.com 11-07-2012 06:39 AM

Re: Logging output to be redirected to a particular folder
 
Thanks ...this works perfectly fine now.

On Tuesday, November 6, 2012 11:28:46 PM UTC+5:30, Prasad, Ramit wrote:
> Dennis Lee Bieber wrote:
>
> >

>
> > On Tue, 06 Nov 2012 13:26:11 +0100, Peter Otten <__peter__@web.de>

>
> > declaimed the following in gmane.comp.python.general:

>
> >

>
> > > anuradha.raghupathy2010@gmail.com wrote:

>
> [snip]
>
> > > > def main():

>
> > > > logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)

>
> > >

>
> > > Python is case-sensitive. Try:

>
> > >

>
> > > logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)

>
> > >

>
> > The double forward slashes might also be confusing... At the least,

>
> > unneeded...

>
> >

>
> > >>> import os.path

>
> > >>> print os.path.normpath("c://somefile.log")

>
> > c:\somefile.log

>
> > >>> print os.path.normpath("c:\\somefile.log")

>
> > c:\somefile.log

>
> > >>> print os.path.normpath("c:\\tryfile.log")

>
> > c:\tryfile.log

>
> > >>> print os.path.normpath("c:\tryfile.log")

>
> > c: ryfile.log

>
> > >>> print os.path.normpath("c:/tryfile.log")

>
> > c:\tryfile.log

>
> > >>>

>
> >

>
> > Doubling back-slashes is needed to avoid the problem of literal

>
> > escapes corrupting the intent...

>
>
>
> Or use the raw literal form r"c:\tryfile.log". I know several
>
> people that prefer to use forward slashes as it works in both
>
> Windows and *nix.
>
>
>
>
>
> ~Ramit
>
>
>
>
>
> This email is confidential and subject to important disclaimers and
>
> conditions including on offers for the purchase or sale of
>
> securities, accuracy and completeness of information, viruses,
>
> confidentiality, legal privilege, and legal entity disclaimers,
>
> available at http://www.jpmorgan.com/pages/disclosures/email.



anuradha.raghupathy2010@gmail.com 11-07-2012 06:39 AM

Re: Logging output to be redirected to a particular folder
 
Thanks ...this works perfectly fine now.

On Tuesday, November 6, 2012 11:28:46 PM UTC+5:30, Prasad, Ramit wrote:
> Dennis Lee Bieber wrote:
>
> >

>
> > On Tue, 06 Nov 2012 13:26:11 +0100, Peter Otten <__peter__@web.de>

>
> > declaimed the following in gmane.comp.python.general:

>
> >

>
> > > anuradha.raghupathy2010@gmail.com wrote:

>
> [snip]
>
> > > > def main():

>
> > > > logging.basicConfig(Filename='c://myapp.log', level=logging.ERROR)

>
> > >

>
> > > Python is case-sensitive. Try:

>
> > >

>
> > > logging.basicConfig(filename='c://myapp.log', level=logging.ERROR)

>
> > >

>
> > The double forward slashes might also be confusing... At the least,

>
> > unneeded...

>
> >

>
> > >>> import os.path

>
> > >>> print os.path.normpath("c://somefile.log")

>
> > c:\somefile.log

>
> > >>> print os.path.normpath("c:\\somefile.log")

>
> > c:\somefile.log

>
> > >>> print os.path.normpath("c:\\tryfile.log")

>
> > c:\tryfile.log

>
> > >>> print os.path.normpath("c:\tryfile.log")

>
> > c: ryfile.log

>
> > >>> print os.path.normpath("c:/tryfile.log")

>
> > c:\tryfile.log

>
> > >>>

>
> >

>
> > Doubling back-slashes is needed to avoid the problem of literal

>
> > escapes corrupting the intent...

>
>
>
> Or use the raw literal form r"c:\tryfile.log". I know several
>
> people that prefer to use forward slashes as it works in both
>
> Windows and *nix.
>
>
>
>
>
> ~Ramit
>
>
>
>
>
> This email is confidential and subject to important disclaimers and
>
> conditions including on offers for the purchase or sale of
>
> securities, accuracy and completeness of information, viruses,
>
> confidentiality, legal privilege, and legal entity disclaimers,
>
> available at http://www.jpmorgan.com/pages/disclosures/email.




All times are GMT. The time now is 03:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.