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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'args': 0.07; 'subject:file': 0.07; 'main()': 0.09; 'parsing': 0.09; 'commandline': 0.16; 'logger': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Logging': 0.16; 'variants': 0.16; 'weird': 0.16; 'all,': 0.19; 'result.': 0.19; 'import': 0.22; 'shell': 0.22; 'this?': 0.23; 'logging': 0.26; 'tried': 0.27; 'function': 0.29; 'sets': 0.30; 'code': 0.31; 'lines': 0.31; 'file': 0.32; 'there.': 0.32; 'figure': 0.32; 'interface': 0.32; "can't": 0.35; 'but': 0.35; 'really': 0.36; 'crazy': 0.36; 'doing': 0.36; 'charset:us- ascii': 0.36; 'thanks': 0.36; 'should': 0.36; 'application': 0.37; 'configured': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'how': 0.40; 'show': 0.63; 'received:109': 0.72; 'received:(helo localhost)': 0.91 Date: Sun, 27 Oct 2013 02:04:58 +0200 From: Johannes Findeisen To: python-list@python.org Subject: Logging to file and not to console X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.22; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Sun, 27 Oct 2013 08:34:38 +0100 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382859279 news.xs4all.nl 15889 [2001:888:2000:d::a6]:34798 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57728 Hi all, I am going crazy with logging. I have an application which sets up logging after parsing the args in the main() funktion. It needs to be setup after parsing the args because I can set the loglevel via commandline flags. I have tried many variants on how to do that but every time with an weird result. What I want is logging in from all libs and really understand that doing this should be enough there: from logging import getLogger logger = getLogger(__name__) But, I need to setup the logger in the main() function to log only to a file and not to console because my application has an own shell interface which should not be spammed with log messages - never a message should show up there. I think it should be only some few lines of code but I can't figure that out. The logger should be configured to have a max file size and rotate logfiles. Can someone help me with this? Thanks in advance, Johannes