Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75725
| 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 | <a.nandagoban@traxens.com> |
| 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" <a.nandagoban@traxens.com> |
| To | "'Peter Otten'" <__peter__@web.de>, <python-list@python.org> |
| References | <003d01cfafe2$e0668ac0$a133a040$@traxens.com> <lro1j7$r2d$1@ger.gmane.org> <lro39e$f7u$1@ger.gmane.org> <lro3rl$pdb$1@ger.gmane.org> |
| In-Reply-To | <lro3rl$pdb$1@ger.gmane.org> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12663.1407231981.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
-----Message d'origine-----
De : Python-list
[mailto:python-list-bounces+a.nandagoban=traxens.com@python.org] De la part
de Peter Otten
Envoyé : Monday, August 4, 2014 4:03 PM
À : python-list@python.org
Objet : Re: creating log file with Python logging module
Peter Otten wrote:
> Peter Otten wrote:
>
>> You won't see a rollover if you restart it.
>
> Sorry, I tried it and the above statement is wrong.
[Arulnambi Nandagoban]
> logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s -
> %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', level = logging.DEBUG,
> filename=Ffilename, filemode='w')
>
> logger = logging.getLogger(__name__)
>
> hdlr = TimedRotatingFileHandler(Ffilename, when='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='%(asctime)s - %(name)s - %(levelname)s -
%(message)s', datefmt='%a, %d %b %Y %H:%M:%S')
logHandler = TimedRotatingFileHandler(Ffilename,when="D")
logFormatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s -
%(message)s', datefmt='%a, %d %b %Y %H:%M:%S')
logHandler.setFormatter( logFormatter )
logger = logging.getLogger(__name__ )
logger.addHandler( logHandler )
logger.setLevel( logging.DEBUG )
The above code works according to my need that is,
- 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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: creating log file with Python logging module "Arulnambi Nandagoban" <a.nandagoban@traxens.com> - 2014-08-05 11:43 +0200
csiph-web