Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:Python': 0.06; 'subject:file': 0.07; 'restart': 0.09; 'subject:module': 0.09; 'python': 0.11; 'de\xa0:': 0.16; 'logger': 0.16; 'skip:[ 60': 0.16; 'subject:log': 0.16; 'to:addr:web.de': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'print': 0.22; 'creating': 0.23; 'skip:% 10': 0.24; 'skip:l 30': 0.24; 'sorry,': 0.24; 'file.': 0.24; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'tried': 0.27; 'statement': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'file': 0.32; 'url:python': 0.33; 'monday,': 0.33; 'skip:t 40': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:it': 0.37; 'email addr:python.org': 0.37; 'level': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'system.': 0.39; 'according': 0.40; 'url:mail': 0.40; 'august': 0.61; 'skip:t 30': 0.61; 'save': 0.62; 're:': 0.63; 'email name :python-list': 0.65; 'received:46': 0.66; 'day': 0.76; 'otten': 0.84; 'replicate': 0.84 X-Rid: a.nandagoban@traxens.com@46.218.201.210 From: "Arulnambi Nandagoban" To: "'Peter Otten'" <__peter__@web.de>, References: <003d01cfafe2$e0668ac0$a133a040$@traxens.com> In-Reply-To: Subject: RE: creating log file with Python logging module Date: Tue, 5 Aug 2014 11:43:35 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFq4S+9ce7VN6onWt9RpONBDgwvXAGLBFeNAwxCiUYB7dw82pxXN6dQ Content-Language: en-us 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: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407231981 news.xs4all.nl 2886 [2001:888:2000:d::a6]:36664 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75725 -----Message d'origine----- De=A0: Python-list [mailto:python-list-bounces+a.nandagoban=3Dtraxens.com@python.org] De la = part de Peter Otten Envoy=E9=A0: Monday, August 4, 2014 4:03 PM =C0=A0: python-list@python.org Objet=A0: Re: creating log file with Python logging module Peter Otten wrote: > Peter Otten wrote: >=20 >> You won't see a rollover if you restart it. >=20 > Sorry, I tried it and the above statement is wrong. [Arulnambi Nandagoban] > logging.basicConfig(format=3D'%(asctime)s - %(name)s - %(levelname)s - = > %(message)s', datefmt=3D'%a, %d %b %Y %H:%M:%S', level =3D = logging.DEBUG,=20 > filename=3DFfilename, filemode=3D'w') >=20 > logger =3D logging.getLogger(__name__) >=20 > hdlr =3D TimedRotatingFileHandler(Ffilename, when=3D'midnight') My alternative theory about what might be going wrong: you are using the same file in logging.basicConfig() and the TimedRotatingFileHandler. But I cannot replicate the problem on my (linux) system. -- https://mail.python.org/mailman/listinfo/python-list Hello, Thank you for response !!! -- Config.py: import logging from logging.handlers import TimedRotatingFileHandler import os import time logging.basicConfig(format=3D'%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt=3D'%a, %d %b %Y %H:%M:%S') logHandler =3D TimedRotatingFileHandler(Ffilename,when=3D"D") logFormatter =3D logging.Formatter('%(asctime)s - %(name)s - = %(levelname)s - %(message)s', datefmt=3D'%a, %d %b %Y %H:%M:%S') logHandler.setFormatter( logFormatter ) logger =3D logging.getLogger(__name__ ) logger.addHandler( logHandler ) logger.setLevel( logging.DEBUG ) The above code works according to my need that is,=20 - print log in console as well as save log in a file every day By adding logging.basicConfig, log is printed in both console and saved = in log file. -- nambi