Logging output to be redirected to a particular folder

Discussion in 'Python' started by anuradha.raghupathy2010@gmail.com, Nov 6, 2012.

  1. Guest

    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()
     
    , Nov 6, 2012
    #1
    1. Advertising

  2. Peter Otten Guest

    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()
     
    Peter Otten, Nov 6, 2012
    #2
    1. Advertising

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

    > 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
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Nov 6, 2012
    #3
  4. Dennis Lee Bieber wrote:

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

    > > 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.
     
    Prasad, Ramit, Nov 6, 2012
    #4
  5. Guest

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

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

    >
    > >

    >
    > > > 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.
     
    , Nov 7, 2012
    #5
  6. Guest

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

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

    >
    > >

    >
    > > > 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.
     
    , Nov 7, 2012
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paras Wadehra
    Replies:
    1
    Views:
    1,814
    =?Utf-8?B?U2F1cmFiaCBOYW5kdQ==?=
    Aug 15, 2004
  2. Stefan Siegl
    Replies:
    0
    Views:
    971
    Stefan Siegl
    Aug 27, 2003
  3. janne
    Replies:
    0
    Views:
    9,547
    janne
    Sep 10, 2004
  4. iceColdFire
    Replies:
    1
    Views:
    459
    Howard
    May 12, 2005
  5. VIC

    Forms Authentication for particular folder

    VIC, Jun 28, 2004, in forum: ASP .Net Security
    Replies:
    3
    Views:
    127
    VicWare
    Jun 28, 2004
Loading...

Share This Page