Logging output to be redirected to a particular folder

  • Thread starter anuradha.raghupathy2010
  • Start date
A

anuradha.raghupathy2010

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()
 
P

Peter Otten

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)
 
D

Dennis Lee Bieber

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...

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

Prasad, Ramit

Dennis said:
(e-mail address removed) 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...


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.
 
A

anuradha.raghupathy2010

Thanks ...this works perfectly fine now.

declaimed the following in gmane.comp.python.general:
(e-mail address removed) 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,








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.
 
A

anuradha.raghupathy2010

Thanks ...this works perfectly fine now.

declaimed the following in gmane.comp.python.general:
(e-mail address removed) 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,








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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top