Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.06; 'debug': 0.07; 'skip:% 20': 0.09; 'subject:()': 0.09; 'python': 0.11; 'subject:Logging': 0.16; 'module': 0.19; 'input': 0.22; 'file.': 0.24; 'logging': 0.26; 'shown': 0.26; 'required.': 0.27; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; '(2)': 0.35; 'etc': 0.35; 'received:google.com': 0.35; '8bit%:17': 0.36; '8bit%:9': 0.36; 'application': 0.37; 'level': 0.37; '8bit%:4': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'ensure': 0.60; 'logged': 0.60; 'guarantee': 0.63; 'provide': 0.64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=lDCaf3oG5MR4+N3bPk675WXeoMWozMisxxeqwD6HI0E=; b=eM5DpdUDJtSd+HslUzegpdeom4ZxhYTzAQ3Lx4cV1GZO+5BZJCmF2M4pXAddEW/uOj 5NLGY9/e7iyFlTQv0FGLtoOBp/QDasAKrJZqoGm7H5auMqclXVmNBO19qG7Da7IFt9Mf OjrCIqYkLRlHWARil4Ul0JYBQfoQ19lejKJMLSUV02nIUIb4G1fLme/cWSSTMNnbTsZu jVL58CD6mMf1ip2unlrkcSeE49T23xqa7PdZGdsgs0IT1RMr5aMWqpF9yeH6hE0A3sq7 HR0g0nGvx8AB02LNKY8neRTe+LvkB80nqN1ZGxXHU6DQDWjJGGP87QDCFLuSUHLgBUzm 6hwA== MIME-Version: 1.0 X-Received: by 10.152.3.229 with SMTP id f5mr2474797laf.94.1416566883188; Fri, 21 Nov 2014 02:48:03 -0800 (PST) Date: Fri, 21 Nov 2014 16:18:03 +0530 Subject: Python Logging and printf() From: Ganesh Pal To: python-list@python.org Content-Type: multipart/alternative; boundary=089e013d182adf873705085c2d6a X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416567208 news.xs4all.nl 2908 [2001:888:2000:d::a6]:60217 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6745 X-Received-Body-CRC: 762841953 Xref: csiph.com comp.lang.python:81195 --089e013d182adf873705085c2d6a Content-Type: text/plain; charset=UTF-8 Hi Team , Iam using the python logging module to log the events for my application into a log file . I have set the logging level to DEBUG as shown below logging.basicConfig(filename=options.log_file, level=logging.DEBUG, format='%(asctime)s %(levelname)s:%(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') iam also using logging.warning(),logging.error(),logging.info() etc as and when required. Please provide your input on the below questions. (1). How do i guarantee that all console messages will be logged into the logfile ? (2) I feel the need to retain few print(), how do I ensure the print() messages are also logged into the log file. Regards, Ganesh --089e013d182adf873705085c2d6a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Team ,

Iam using the python logging = module to log the events for my application into a log file .
I have set the logging level to DEBUG =C2=A0as shown below=C2= =A0

logging.basicConfig(filename=3Doptions.lo= g_file,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 level=3Dlogging.DEBUG,
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 forma= t=3D'%(asctime)s %(levelname)s:%(message)s',
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 d= atefmt=3D'%m/%d/%Y %I:%M:%S %p')

=C2= =A0iam also using logging.warning(),log= ging.error(),logging.info() etc =C2=A0as and when required.
=
Please provide your input on the below questions.

<= /span>
(1). How do i=C2=A0guarantee=C2=A0that =C2=A0all console=C2=A0= messages=C2=A0will be logged into the logfile ?
(2) I f= eel the =C2=A0need to retain few print(), how do I ensure the print() messa= ges are also logged into the log file.



Regards,
Ganesh
--089e013d182adf873705085c2d6a--