Deutsch English Français Italiano |
<mailman.104.1731489134.4695.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail From: Roel Schroeven <roel@roelschroeven.net> Newsgroups: comp.lang.python Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself Date: Wed, 13 Nov 2024 10:12:07 +0100 Lines: 50 Message-ID: <mailman.104.1731489134.4695.python-list@python.org> References: <87v7wt986z.fsf@zedat.fu-berlin.de> <CAJQBtg=UOiOmmHa25EUZtrZO19F1O0_VxCO6gWjZ5ebAMHnXCA@mail.gmail.com> <mailman.92.1731341107.4695.python-list@python.org> <875xosyfr0.fsf@zedat.fu-berlin.de> <CAJQBtg=nr+KC5iz_WY7nqkGK+YBEWAPq40ksaWJCAOT_+=pHxg@mail.gmail.com> <5f972e7d-e72d-459b-9148-0af977a82ead@roelschroeven.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de qTZm5Gf59o6v8BOEyknEYg3nfHPiMcMK9+mQZDJVdsow== Cancel-Lock: sha1:GHfNHxoPPUOkdjIoG/Ig+6NfClI= sha256:uH/NMgO2yxLWlhhhujLNphXDsIAqzP7iNY0+efvcs0k= Return-Path: <roel@roelschroeven.net> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=roelschroeven.net header.i=@roelschroeven.net header.b=mD8MDZ7R; dkim-adsp=pass; dkim-atps=neutral X-Spam-Status: OK 0.117 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.77; '*S*': 0.00; 'debugging': 0.07; 'subject:name': 0.07; 'wrong.': 0.07; 'fact,': 0.09; 'log': 0.12; 'category,': 0.16; 'command.': 0.16; 'database,': 0.16; 'filename': 0.16; 'impossible': 0.16; 'infra': 0.16; 'ldap': 0.16; 'logs': 0.16; 'moderately': 0.16; 'pipe': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.163': 0.16; 'received:internal': 0.16; 'received:messagingengine.com': 0.16; 'run,': 0.16; 'schreef': 0.16; 'server,': 0.16; 'wider': 0.16; 'worlds.': 0.16; 'problem': 0.16; "aren't": 0.19; 'figure': 0.19; 'to:addr:python-list': 0.20; 'option': 0.20; 'written': 0.22; 'first,': 0.22; 'subject:file': 0.22; 'past': 0.25; 'saying': 0.25; 'cannot': 0.25; 'behavior': 0.26; 'task': 0.26; 'output': 0.28; 'header:User-Agent:1': 0.30; 'am,': 0.31; 'program': 0.32; "doesn't": 0.32; 'files,': 0.32; 'but': 0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'mean': 0.34; 'files': 0.36; 'really': 0.36; 'people': 0.36; 'change': 0.36; "it's": 0.37; 'file': 0.38; 'way': 0.38; 'put': 0.38; 'both': 0.38; 'use': 0.39; 'quite': 0.39; 'single': 0.39; 'neither': 0.39; 'to.': 0.39; 'advantage': 0.40; 'program.': 0.40; 'something': 0.40; 'want': 0.40; "there's": 0.61; 'day,': 0.62; 'gives': 0.62; 'send': 0.62; 'simply': 0.63; 'feel': 0.63; 'email': 0.63; 'your': 0.64; 'time,': 0.67; 'that,': 0.68; 'per': 0.68; 'right': 0.68; 'james': 0.68; 'during': 0.69; '"you': 0.69; 'currently,': 0.69; 'days,': 0.69; 'drop': 0.69; 'natural': 0.69; 'received:202': 0.69; 'older': 0.70; 'care': 0.71; 'chance': 0.71; 'low': 0.74; 'records': 0.75; 'released': 0.75; 'potentially': 0.76; 'left': 0.83; 'etc.,': 0.84; 'rotating': 0.84; 'subject: \n ': 0.84; 'property': 0.88; 'fool': 0.91; 'hand.': 0.91; 'reliable.': 0.91; 'subject:than': 0.91; 'audience.': 0.97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= roelschroeven.net; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1731489129; x=1731575529; bh=D2PXGbxk1SOckylLzS3Y8 CBr7XcFtJU98R1BlBXRy70=; b=mD8MDZ7RnpJ5NLuCqHP+eWuNXSBmLIah757XC z/+M/2ElAFLi1kQBfQKJejyKwxhC57QspTL3JQaaeLPFlQ/X4Z1gtUyYIvDmKwJY UsiEqL5si60Y+z64xNsZE3mwmKZvTASl0Q07573KibTykNZ+YBkdvlqK5TpBn/U2 G8ErZpo0EtaPQ8kL3PcBhkpnCUvawll6mVVX/K5Kk3Guw2glG2yHx53qJEECv05d yD00viCrgnAjKJml24lM7u1Ps4UkdAlm4ecrYZc7ba3UYdoPJS7Jqo5v/jAqWVyU mr1erYvtvTFXEA3qbYl00FhF02NXXC3t7T1uLqOWV6TVe/Bmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1731489129; x=1731575529; bh=D 2PXGbxk1SOckylLzS3Y8CBr7XcFtJU98R1BlBXRy70=; b=IOPudk7yyZxm3b++t lGaUBQrabVkD+775/SS2wpoPdLGFoRSroUj6IN1COaLoclF1VYWaFGO6xG5hUy15 m+VKXU5Yf2aYNEJuFEBzay45XlvrNqtN94mUKD0ZLeULb2zUDFyQnANufZ3+MSpg T8g+4AQgW49NrRVaGFstRHE7yQOmUuiMFrh7iEjj7/36j7dLIt1QZ4U2/PcpQzaI YK/9l7FfFe/lORJtjUSqtXwZSbvC1cHhYerKbrCT3YWY2kkWOo0Z3xIKgIEWdCXl yNu8JBH70nZQ639Jg4A6LWhZwkuCVf2SHR5BLM9Go/f05kn7mbRpAfvvI6I4D4uw p2CxQ== X-ME-Sender: <xms:aW00Z3s-n36HfW6u87iKxd31iYD6hNv1FFe97QEMJLg8nX81FTcXCQ> <xme:aW00Z4c4SoerokGBArsWJppGTysoT2yo5vgHu_0k9qZsMg_s30K_5jbeIIt_pLgk7 Udo-gcBaeie> X-ME-Received: <xmr:aW00Z6yzN2_Ml8F--ksHqhX4wuNrQ2OeDcnsp7Orxhs8Vr3dhDxirsqrXZh6hJfDu_ZaIdpbVNZglMiv3M3DMoTe7pdwm5H553_glFRDiMUYnms> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrvddtgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuf fvfhfhjggtgfesthejredttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghn uceorhhovghlsehrohgvlhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrh hnpeekgfefudeuhedvkeefjeehvdeljeelfffhtdegteejtdeufeeffefhveetudffueen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlh esrhhovghlshgthhhrohgvvhgvnhdrnhgvthdpnhgspghrtghpthhtohepuddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrd horhhg X-ME-Proxy: <xmx:aW00Z2N0l3VK2_L8TNgZXy3-2rx4Z0gtzDf1E93fc2v9wnsxZ_QGuA> <xmx:aW00Z39ElYWvPY9OBRaDTlZtNadAQLhPq45ND3S6n1wfInZT9NOWLA> <xmx:aW00Z2XgEsTEiHYM8saOW_CUDA87zWASHiEi0gmgLByL_dn7ZTw-KA> <xmx:aW00Z4faXVes-vxSpF8RKCw1_0EEI5GLuj9sCldZ_MJapRziU-vtJw> <xmx:aW00ZxmJdaRcHofgNi-GgzCx_fSaOYaoiIfEwQW-ZbbVmCLGlDOf_I8O> Feedback-ID: i8e5b41ae:Fastmail User-Agent: Mozilla Thunderbird Content-Language: nl, en-US In-Reply-To: <CAJQBtg=nr+KC5iz_WY7nqkGK+YBEWAPq40ksaWJCAOT_+=pHxg@mail.gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 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: <https://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> X-Mailman-Original-Message-ID: <5f972e7d-e72d-459b-9148-0af977a82ead@roelschroeven.net> X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de> <CAJQBtg=UOiOmmHa25EUZtrZO19F1O0_VxCO6gWjZ5ebAMHnXCA@mail.gmail.com> <mailman.92.1731341107.4695.python-list@python.org> <875xosyfr0.fsf@zedat.fu-berlin.de> <CAJQBtg=nr+KC5iz_WY7nqkGK+YBEWAPq40ksaWJCAOT_+=pHxg@mail.gmail.com> Bytes: 10034 Op 12/11/2024 om 20:10 schreef Left Right via Python-list: > > I am not entirely convinced by NB2. I am, in fact, a sort of sysadmin > > person and most of my programs write to a log file. The programs are > > also moderately complex, so a single program might access a database, > > query an LDAP server, send email etc., so potentially quite a lot can go > > wrong. They are also not programs whose output I would pipe to another > > command. What would be the advantage of logging to stderr? Quite apart > > from that, I find having a log file a useful for debugging when I am > > developing. > > First, the problem with writing to files is that there is no way to > make these logs reliable. This is what I mean by saying these are > unreliable: since logs are designed to grow indefinitely, the natural > response to this design property is log rotation. But, it's > impossible to reliably rotate a log file. There's always a chance > that during the rotation some log entries will be written to the file > past the point of rotation, but prior to the point where the next logs > volume starts. What I most often do is use one logfile per day, with the date in the filename. Then simply delete all files older than 7 days, or 30 days, or whatever is useful for the task at hand. Not only does that sidestep any issues with rotating logs, but I also find it's very useful to have the date in the filename. > Of course, if you only administer your own computer, and you have low > single digits programs to run, and their behavior doesn't change > frequently, and you don't care to drop some records every now and > then... it's OK to log to files directly from a program. But then you > aren't really in the sysadmin / infra / ops category, as you are more > of a hobby enthusiast. I would not use my scheme for something released to a wider audience. For in-house software though, I like that I can easily put each application's logs next to its other data files, and that I don't have to figure out how to get the system's own log infrastructure to work is I want it to. > Finally, if you want your logs to go to a file, and currently, your > only option is stderr, your shell gives you a really, really simple > way of redirecting stderr to a file. I feel this is the worst of both worlds. Now your program doesn't have any control over filename or log expiration, and neither does your system's logging infrastructure. You just get one indefinitely growing log file. -- "You can fool some of the people all the time, and all of the people some of the time, but you cannot fool all of the people all of the time." -- Abraham Lincoln "You can fool too many of the people too much of the time." -- James Thurber