Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18019
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'handler': 0.04; 'subject:module': 0.04; '__name__': 0.09; 'handlers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'skip:l 60': 0.09; 'subject:python': 0.10; 'configure': 0.10; '"__main__":': 0.16; 'class;': 0.16; 'getting.': 0.16; 'subject:logging': 0.16; 'this:': 0.16; 'subject:question': 0.17; 'wrote:': 0.18; 'simpler': 0.18; 'input': 0.22; 'header:In-Reply-To:1': 0.22; 'all:': 0.23; 'documented': 0.23; 'parameters': 0.25; 'module': 0.26; "i'm": 0.26; 'skip:[ 10': 0.27; 'pass': 0.29; 'error': 0.29; 'pm,': 0.29; 'server': 0.30; 'generally': 0.30; 'keeps': 0.30; 'skip:% 10': 0.30; 'url:library': 0.31; 'version': 0.32; 'header :User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'on,': 0.34; 'to:addr:python-list': 0.34; 'url:python': 0.36; 'file': 0.36; 'received:au': 0.36; 'enough': 0.38; 'using': 0.38; 'received:org': 0.38; 'some': 0.38; 'e.g.': 0.39; 'url:docs': 0.39; 'url:org': 0.39; 'should': 0.39; 'logs': 0.39; "it's": 0.40; 'to:addr:python.org': 0.40; 'here:': 0.66; 'observer': 0.84; 'skip:l 80': 0.84; 'so:': 0.84; 'subject::': 0.87; 'received:110': 0.95 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Lie Ryan <lie.1296@gmail.com> |
| Subject | Re: python logging module:a quick question |
| Date | Tue, 27 Dec 2011 21:48:58 +1100 |
| References | <4EF9651F.7070806@tysdomain.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 110-175-240-90.static.tpgi.com.au |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 |
| In-Reply-To | <4EF9651F.7070806@tysdomain.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4130.1324982957.27778.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1324982957 news.xs4all.nl 6872 [2001:888:2000:d::a6]:58823 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18019 |
Show key headers only | View raw
On 12/27/2011 05:26 PM, Littlefield, Tyler wrote: > Hello all: > I have a basic server I am working on, and wanted some input with an > error I'm getting. > I am initializing the logger like so: > if __name__ == "__main__": > observer = log.PythonLoggingObserver() > observer.start() > logging.basicConfig(filename='logs/server.log', level=logging.DEBUG, > format='%(asctime)s [%(levelname)s] %(module)s:%(funcname)s:%(lineno)d > %(message)s') > logger = logging.getLogger() > logger.addHandler(logging.handlers.TimedRotatingFileHandler) You should pass an **instance** of the handler, not the class; so it should look like this: logger.addHandler(logging.handlers.TimedRotatingFileHandler(...)) if you want to configure the handler, e.g. configure how often the log file is rotated, you can do it by passing parameters to the handler's constructure, e.g.: logger.addHandler(logging.handlers.TimedRotatingFileHandler(filename='/foo/mylog.log', when='d', interval=3, backupCount=5)) will create a handler that will log to the file /foo/mylog.log and rotate the log every 3 days and keeps the last 5 logs for backup. the logging handlers are documented over here: http://docs.python.org/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler Note that if you're using a recent enough version of python, it's also possible to configure the logging module using a dictionary-based configuration. Dictionary-based configuration is generally simpler than code-based configuration.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python logging module:a quick question Lie Ryan <lie.1296@gmail.com> - 2011-12-27 21:48 +1100
csiph-web