Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75687

creating log file with Python logging module

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'handler': 0.05; 'root': 0.05; 'subject:Python': 0.06; 'debug': 0.07; 'skip:l 60': 0.07; 'subject:file': 0.07; 'subject:module': 0.09; 'logger': 0.16; 'subject:log': 0.16; 'sys.stderr': 0.16; 'all,': 0.19; 'module': 0.19; 'skip:f 30': 0.19; 'import': 0.22; 'config': 0.24; 'skip:% 10': 0.24; 'skip:l 30': 0.24; 'file.': 0.24; 'sort': 0.25; 'define': 0.26; 'logging': 0.26; 'code:': 0.26; 'skip:" 20': 0.27; "skip:' 10": 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'subject:with': 0.35; 'info': 0.35; 'display': 0.35; 'problem.': 0.35; 'but': 0.35; 'add': 0.35; 'url:rec-html40': 0.35; "didn't": 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'received:it': 0.37; 'application': 0.37; 'url:microsoft': 0.37; 'level': 0.37; 'skip:o 20': 0.38; 'configured': 0.38; 'writes': 0.38; 'url:office': 0.38; 'to:addr:python-list': 0.38; 'url:schemas': 0.38; 'url:omml': 0.39; 'url:2004': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'tell': 0.60; 'skip:t 30': 0.61; 'new': 0.61; 'received:46': 0.66; 'skip:w 40': 0.68; 'skip:w 30': 0.69; 'day': 0.76
X-Rid a.nandagoban@traxens.com@46.218.201.210
From "Arulnambi Nandagoban" <a.nandagoban@traxens.com>
To <python-list@python.org>
Subject creating log file with Python logging module
Date Mon, 4 Aug 2014 14:51:57 +0200
MIME-Version 1.0
Content-Type multipart/alternative; boundary="----=_NextPart_000_003E_01CFAFF3.A3F35260"
X-Mailer Microsoft Outlook 14.0
Thread-Index Ac+v4t/C36Qc1W3qQHWrd7q72uhRjw==
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.12639.1407156882.18130.python-list@python.org> (permalink)
Lines 161
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407156882 news.xs4all.nl 2949 [2001:888:2000:d::a6]:58114
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75687

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello all,

 

I am using logging module for my application to log all debug information. I
configured it create a new log file every day with

"TimedRotatingFileHandler".  I display debug message in console as well.
But I didn't see creation of new file. Can someone help me to sort out this
problem. Following is config code:

 

import logging

from logging.handlers import TimedRotatingFileHandler

 

Ffilename = os.path.join(dir_path, 'Pyserverlog')

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

logger.addHandler(hdlr)

# define a Handler which writes INFO messages or higher to the sys.stderr

console = logging.StreamHandler()

console.setLevel(logging.DEBUG)

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s -
%(message)s')

# tell the handler to use this format

console.setFormatter(formatter)

# add the handler to the root logger

logging.getLogger('').addHandler(console)

 

--

nambi

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

creating log file with Python logging module "Arulnambi Nandagoban" <a.nandagoban@traxens.com> - 2014-08-04 14:51 +0200

csiph-web