Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You are dishonest, but never to the point of hurting a friend.


comp / comp.lang.python / Re: FileNotFoundError thrown due to file name in file, rather than file itself

SubjectAuthor
* FileNotFoundError thrown due to file name in file, rather than file itselfLoris Bennett
+* Re: FileNotFoundError thrown due to file name in file, rather than file itselfLeft Right
|`* Re: FileNotFoundError thrown due to file name in file, rather than file itselfLoris Bennett
| +* Re: FileNotFoundError thrown due to file name in file, rather than file itselfLeft Right
| |`* Re: FileNotFoundError thrown due to file name in file, rather than file itselfGreg Ewing
| | `- Re: FileNotFoundError thrown due to (Posting On Python-List Prohibited)Lawrence D'Oliveiro
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfMats Wichmann
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfChris Angelico
| +* Re: FileNotFoundError thrown due to file name in file, rather than file itselfLoris Bennett
| |`- Re: FileNotFoundError thrown due to file name in file, rather than file itselfBarry
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfRoel Schroeven
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfMichael Torrie
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfLeft Right
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfChris Angelico
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfD'Arcy Cain
| +- Re: FileNotFoundError thrown due to file name in file, rather than file itselfEthan Furman
| `* Re: FileNotFoundError thrown due to file name in file, rather than file itselfMichael Torrie
|  `- Re: FileNotFoundError thrown due to file name in file, rather than file itselfJon Ribbens
+- Re: FileNotFoundError thrown due to file name in file, rather than file itselfdieter.maurer
+- Re: FileNotFoundError thrown due to (Posting On Python-List Prohibited)Lawrence D'Oliveiro
`* Re: FileNotFoundError thrown due to file name in file, rather than file itselfChris Angelico
 +* Re: FileNotFoundError thrown due to file name in file, rather than file itselfLoris Bennett
 |+- Re: FileNotFoundError thrown due to file name in file, rather than file itselfdieter.maurer
 |`- Re: FileNotFoundError thrown due to file name in file, rather than file itselfKushal Kumaran
 `- Re: FileNotFoundError thrown due to file name in file, rather than file itselfLoris Bennett

1
Subject: FileNotFoundError thrown due to file name in file, rather than file itself
From: Loris Bennett
Newsgroups: comp.lang.python
Organization: FUB-IT, Freie Universität Berlin
Date: Mon, 11 Nov 2024 14:05 UTC
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: FileNotFoundError thrown due to file name in file, rather than file itself
Date: Mon, 11 Nov 2024 15:05:56 +0100
Organization: FUB-IT, Freie Universität Berlin
Lines: 45
Message-ID: <87v7wt986z.fsf@zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de Gr3B2vn40MiLj7gPnn8zbA/p7eWAQyeflpcjlkqrqxqTBy
Cancel-Lock: sha1:tbACYwZLYVA6QcQm/6gcT2IoWyM= sha1:6aRou9KsRIB4I1L/IWFTuAsxrBc= sha256:70X+oy+bBxG3IUf1rYgxMcbOGh1X8IUzTGyeY1/a9Z4=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
View all headers

Hi,

I have the following in my program:

try:
logging.config.fileConfig(args.config_file)
config = configparser.ConfigParser()
config.read(args.config_file)
if args.verbose:
print(f"Configuration file: {args.config_file}")
except FileNotFoundError:
print(f"Error: configuration file {args.config_file} not found. Exiting.")
sys.exit(0)

and when I ran the program I got the error

Error: configuration file /usr/local/etc/sc_mailer not found. Exiting.

However, this file *does* exist and *can* be read. By checking the
'filename' attribute of the exception I discovered that the problem was
the log file defined *in* the config file, namely

[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=defaultFormatter
args=('/var/log/my_prog.log', 'a')

This log file did not exist. The exception is thrown by

logging.config.fileConfig(args.config_file)

My questions are:

1. Should I be surprised by this behaviour?
2. In terms of generating a helpful error message, how should one
distinguish between the config file not existing and the log file not
existing?

Cheers,

Loris

--
This signature is currently under constuction.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Left Right
Newsgroups: comp.lang.python
Date: Mon, 11 Nov 2024 16:04 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivokon@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Mon, 11 Nov 2024 17:04:52 +0100
Lines: 80
Message-ID: <mailman.92.1731341107.4695.python-list@python.org>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAJQBtg=UOiOmmHa25EUZtrZO19F1O0_VxCO6gWjZ5ebAMHnXCA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 7Q4FlMQx4wbszB5QStolGwDBAnR1BSEWRjouw2pOoaGg==
Cancel-Lock: sha1:hpDTbC/TzYBM8Qabkh4pS4T4txQ= sha256:fgdM3dImhvZEbb3VmhmFTsHJlNZNITepqSmLRgJiLKs=
Return-Path: <olegsivokon@gmail.com>
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=gmail.com header.i=@gmail.com header.b=XnBcuM1x;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'salt': 0.04; 'error:':
0.05; 'programming.': 0.05; 'subject:name': 0.07; 'url:mailman':
0.09; 'cases.': 0.09; 'cc:addr:python-list': 0.09; 'numeric':
0.09; 'reporting': 0.09; 'skip:[ 20': 0.09; 'cheers,': 0.11;
'log': 0.12; 'cc:no real name:2**0': 0.14; 'that.': 0.15;
'url:listinfo': 0.15; 'bennett': 0.16; 'customized': 0.16;
'found.': 0.16; 'generating': 0.16; 'infra': 0.16; 'level,': 0.16;
'logs': 0.16; 'namely': 0.16; 'program:': 0.16; 'received:mail-
qv1-xf30.google.com': 0.16; 'wrote:': 0.16; 'problem': 0.16;
'python': 0.16; 'code.': 0.19; 'cc:addr:python.org': 0.20; 'url-
ip:188.166.95.178/32': 0.20; 'url-ip:188.166.95/24': 0.20;
'language': 0.21; 'exception': 0.22; 'ran': 0.22; 'returns': 0.22;
'subject:file': 0.22; 'version': 0.23; 'code': 0.23; 'url-
ip:188.166/16': 0.24; "i'd": 0.24; 'idea': 0.24; '(and': 0.25;
'anything': 0.25; 'cc:2**0': 0.25; 'tried': 0.26; '11,': 0.26;
'skip:{ 20': 0.26; "wasn't": 0.26; 'creating': 0.27; "isn't":
0.27; 'else': 0.27; 'error': 0.29; 'message-id:@mail.gmail.com':
0.31; 'program': 0.32; 'question': 0.32; 'python-list': 0.32;
'suitable': 0.32; 'but': 0.32; 'unless': 0.32; 'there': 0.33;
'path': 0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com':
0.34; 'printing': 0.34; 'from:addr:gmail.com': 0.34; 'following':
0.35; 'mon,': 0.36; 'source': 0.36; 'those': 0.36; 'missing':
0.37; 'special': 0.37; 'currently': 0.37; "it's": 0.37; 'could':
0.37; 'though': 0.37; 'file': 0.38; 'use': 0.39; 'two': 0.39;
"that's": 0.39; 'still': 0.40; 'case.': 0.40; 'file:': 0.40;
'files.': 0.40; 'should': 0.40; 'tell': 0.60; "there's": 0.61;
'true': 0.63; 'simply': 0.63; 'between': 0.63; 'your': 0.64;
'universal': 0.64; 'bad': 0.67; 'management': 0.68; 'terms': 0.69;
'little': 0.73; 'tools': 0.74; 'skip:f 20': 0.75; 'accordingly.':
0.76; 'choice': 0.76; 'heart': 0.76; 'poor': 0.76; 'potentially':
0.76; 'signature': 0.76; 'discovered': 0.80; 'attribute': 0.84;
'figuring': 0.84; 'subject: \n ': 0.84; 'surprised': 0.84;
'caused': 0.86; 'incorporates': 0.91; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731341104; x=1731945904; darn=python.org;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=psCAT2Lz8xNOvuq7G5JjumRdh7fJ01Wzi95W5VMDFYA=;
b=XnBcuM1x1eh4H8vZGD5n4PIcV3+bsEnB0KYlage2JLKh0NxMr7s115bueWu7FIccyV
F0BITxP//xC+Cu1RqwxaS6Q4lCIT9pdoFGsiAbuSk3GpSZf7eyNxueUs60ePuWNIBaGg
m90fCpXul4wdPVuciFvtDIt59q7LREtK9mhb1q6h3c5/Cv9vx47N9q5molwWmvZ6Ab7M
xyn5I8XpmVFaSEHecOxkHv9XhCnHClRa3yJ36DFhJ3agrLN0jyeifgWamye/8JiexRTV
LtWYwx1dAYMSyqlHtNeMAESL0ACLsl+seLza2TDe3q2aY4Ud7pYVj6/nV5HlynYejQLW
UImA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731341104; x=1731945904;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=psCAT2Lz8xNOvuq7G5JjumRdh7fJ01Wzi95W5VMDFYA=;
b=bOcnrQgmaYwr54m4F1KZx/iTdWuZdCocEImGkHtC9dvsz0+Ihia1AUDtBREDc4ZXRG
OBdQIioXl55xrbJsaG9LTh4RZ9XwIbyL8oX7fVVUTuldnn13wLbjDtnkOg/EylvzJyV/
Vfjki/dr//43iwbELTSzDT85bt4wGkAiK7z7vj8TvQBHti2P64oRGUaeO0RkIxaelU5Q
LPoTu7xPWTOIKZG5U18GYH/K4E9sNIhDO6jzXgcdt/Rcm7EYdePZKSGQbdZdzyVdvbzc
jKYsyU2ywQPtr1uV9qicboQiEkABhZS8UKXWkWMppMsEMHMD6WmU8l2Cv556QjOYwg1/
Y8aw==
X-Gm-Message-State: AOJu0Yyr7to13icAcQjR2DjGLga6ghDgTX80n0P73DEhJHy38pEDAOMx
dA56GpVEwVW5iN5YEOpDivWPwoCCx+WVZE5nVe6hEW42ffx6CJEm3neB5cyG04wLn0nPdo+N2cH
uEJ8N5rfLXX9ppRQLSe8v+EfueLkR1S88
X-Google-Smtp-Source: AGHT+IEhxayK29aZiS6o+MlHoqGZ4BZPATDHF+IbTYo6dENI5esMsz7hBlqn8qWCA4UzIs2NrfOkcIm15+KBakxpfIM=
X-Received: by 2002:a05:6214:398d:b0:6cb:e860:eae6 with SMTP id
6a1803df08f44-6d39e1078abmr160209216d6.5.1731341103908; Mon, 11 Nov 2024
08:05:03 -0800 (PST)
In-Reply-To: <87v7wt986z.fsf@zedat.fu-berlin.de>
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: <CAJQBtg=UOiOmmHa25EUZtrZO19F1O0_VxCO6gWjZ5ebAMHnXCA@mail.gmail.com>
X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de>
View all headers

Poor error reporting is a very common problem in programming. Python
is not anything special in this case. Of course, it would've been
better if the error reported what file wasn't found. But, usually
these problems are stacking, like in your code. Unfortunately, it's
your duty, as the language user, to anticipate those problems and act
accordingly. Now you've learned that the one file you believe that
could be the source for the error isn't the only one--well, adjust
your code to differentiate between those two (and potentially other?)
cases. There's very little else you can do beside that.

NB. On the system level, the error has no information about what file
wasn't found. It simply returns some numeric value (the famous
ENOENT) in case when the system call to open a file fails. Python
could've been more helpful by figuring out what path caused the
problem and printing that in the error message, but it doesn't...
That's why I, myself, never use the vanilla FileNotFoundError, I
always re-rise it with a customized version that incorporates the
information about the missing file in the error message.

NB2. It's always a bad idea to print logs to files. Any sysadmin /
ops / infra person worth their salt will tell you that. The only
place the logs should go to is the standard error. There are true and
tried tools that can pick up logs from that point on, and do with them
whatever your heart desires. That is, of course, unless you are
creating system tools for universal log management (in which case, I'd
question the choice of Python as a suitable language for such a task).
Unfortunately, even though this has been common knowledge for decades,
it's still elusive in the world of application development :|

On Mon, Nov 11, 2024 at 4:00 PM Loris Bennett via Python-list
<python-list@python.org> wrote:
>
> Hi,
>
> I have the following in my program:
>
> try:
> logging.config.fileConfig(args.config_file)
> config = configparser.ConfigParser()
> config.read(args.config_file)
> if args.verbose:
> print(f"Configuration file: {args.config_file}")
> except FileNotFoundError:
> print(f"Error: configuration file {args.config_file} not found. Exiting.")
> sys.exit(0)
>
> and when I ran the program I got the error
>
> Error: configuration file /usr/local/etc/sc_mailer not found. Exiting.
>
> However, this file *does* exist and *can* be read. By checking the
> 'filename' attribute of the exception I discovered that the problem was
> the log file defined *in* the config file, namely
>
> [handler_fileHandler]
> class=FileHandler
> level=DEBUG
> formatter=defaultFormatter
> args=('/var/log/my_prog.log', 'a')
>
> This log file did not exist. The exception is thrown by
>
> logging.config.fileConfig(args.config_file)
>
> My questions are:
>
> 1. Should I be surprised by this behaviour?
> 2. In terms of generating a helpful error message, how should one
> distinguish between the config file not existing and the log file not
> existing?
>
> Cheers,
>
> Loris
>
> --
> This signature is currently under constuction.
> --
> https://mail.python.org/mailman/listinfo/python-list

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: dieter.maurer@online.de
Newsgroups: comp.lang.python
Date: Mon, 11 Nov 2024 17:24 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dieter.maurer@online.de
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file,
rather than file itself
Date: Mon, 11 Nov 2024 18:24:44 +0100
Lines: 33
Message-ID: <mailman.93.1731348414.4695.python-list@python.org>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<26418.15836.335097.984240@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de j4wU7TXqQIYcT5aO1igmuwsge5dGrS4RU0EJjSd/eKzQ==
Cancel-Lock: sha1:3pQAh5qMcqyhRBtQ7O7/s/MzYs8= sha256:/uq2BZ6TRLJOjkEflfN96T25kBVQyncL8jJsUsLQ6sE=
Return-Path: <dieter.maurer@online.de>
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=online.de header.i=dieter.maurer@online.de
header.b=DcDadR6c; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.053
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'received:212.227': 0.07;
'subject:name': 0.07; '(python': 0.09; 'cc:addr:python-list':
0.09; 'subject:, \n ': 0.09; 'log': 0.12; 'cc:no real name:2**0':
0.14; 'bennett': 0.16; 'found.': 0.16; 'generating': 0.16;
'program:': 0.16; 'python': 0.16; 'cc:addr:python.org': 0.20;
'exception': 0.22; 'subject:file': 0.22; 'code': 0.23;
'received:de': 0.23; '(and': 0.25; 'cc:2**0': 0.25; 'skip:{ 20':
0.26; 'error': 0.29; 'received:kundenserver.de': 0.32;
'received:mout.kundenserver.de': 0.32; 'header:In-Reply-To:1':
0.34; 'following': 0.35; '...': 0.37; 'file': 0.38; 'quite': 0.39;
'wrote': 0.39; '(see': 0.40; 'file:': 0.40; 'learn': 0.40;
'should': 0.40; 'likely': 0.61; 'between': 0.63; 'your': 0.64;
'full': 0.64; 'thus': 0.64; 'look': 0.65; 'well': 0.65; 'terms':
0.69; 'raised': 0.70; 'received:80': 0.70; 'major': 0.78;
'clause': 0.84; 'surprised': 0.84; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=online.de;
s=s42582890; t=1731348411; x=1731953211; i=dieter.maurer@online.de;
bh=MN8+j1xHIqyz/dbOcn5PuBRH1fXI+duOHVsAgPg0ugU=;
h=X-UI-Sender-Class:MIME-Version:Content-Type:
Content-Transfer-Encoding:Message-ID:Date:From:To:Cc:Subject:
In-Reply-To:References:cc:content-transfer-encoding:content-type:
date:from:message-id:mime-version:reply-to:subject:to;
b=DcDadR6c5kOFDZ6j9hzuyY7cfwcCGdBzRByH2JjPgize41efhG83RKSuemmSEVJO
cKx2tqUXfVPBfYqnAGTpj8YPh+qISWtfySa/s1yyAPZQce0/wCDFsLUteuR5TVoVy
TticYEesVmv+BhKjyxbNtT17vPZJIojqRt7BE+5IlYSLG4W9vxEYM3p3Y5KMoKzOU
NeYnTlNwBGqHcl0VkZ/ShiE9sfnkCkOV+vlGvLotI18TJEJxNFkuVPXGqYXi9BUtF
nc8XU7dZwOtHmNK5BpQuRAQunLpFXayV55qulfaqx7JaHWDr7Oj1zrulZRMeIadzE
OIIPcpFGQ5t1uZOpvQ==
X-UI-Sender-Class: 6003b46c-3fee-4677-9b8b-2b628d989298
In-Reply-To: <87v7wt986z.fsf@zedat.fu-berlin.de>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-Provags-ID: V03:K1:a584Z6ojDijytenwJlGQtRISlhg8GMsQqoxaxdxN7hdntvh0pAe
MWIjK+TGwSSzN85LDLAk5TSNJoG9i8TiS7ZJK3PT1hxPjp0m4v7eK1FdQH0985d2NNJ1mhz
uOSnYAfePCbf+aSRe8oKsgyywSU8K+PxjAf8bWF1zQ7X4/xJuKUHaoAaunr51fFwnIl5FqS
YsrnAAq0OODOOMWclBISA==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:lMo/raPtesg=;5NJdf8J+09mPr7nDExoo7I5nD/B
yX9lW32g4oW1EJ3GNs9UM4kLVQIGdgZwQwRbIZVyk90QgR8D3arWw17v9GRnZTIkjSS64i4Gd
m9d/xqmyiIecYT3oJZbX9OsrazjHQqSbtBm1oc4DB2cb1Bx/KZFiP1RtBUj8qv7HD/hweIxNs
bQujK2rS/Tdi9E94IDfIsB0RjRp88ElGBdXY2g1ZuDSdwbf9tsWcNrN+XyMoDwLziQst9RA0q
wG0KFMei5hU1RTdUBM9/OKQl6BFvxlVz8kFPRi98y8t0dd8NRUQkvjwqqdBcd+d4parZU+i0Y
GnTfjMhtMSrj4rPCw9xLgLIMv7VMy7vf/CHZKB94NLZeAsxD3zM0k++g1wiv/O/8kAb7x9YL5
7xTLEzdG5GawPLe2ukpSPPcm9Lv9yVaz8ItkjSveV7clwTR1V/0XBdZsLxtCc8V8C7lHwmoeb
5RLC263OFH15JHM16isRr6TZ+eZMF9GlSx7TOJxwwELXxqWulC6TpC+lGnHK+CDAKQnLdBDoB
Go8t8m5x7zSVZvUQuYTrE25//JM3rK4M8uvmx9dSHFuyYj/YykO7KDAA8zCVCmt8etQ9rFUqD
tFoPWwbJOKRet+mFpotcvXOzW3LdARyk8TIHUzBdoiaW/87Dzy4EFf/LulEX2/1w176bLmwMp
Fh7sTDSxDKPhkhYMN7/n6SDZKrmFjDi0OAOyErUNM70/P/PawjDX3Vgk2zI9Bngo6BA6TSKkt
FkkonYXVpDrLC1qhgkQUhx6gDEKYpOxQQ==
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: <26418.15836.335097.984240@ixdm.fritz.box>
X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de>
View all headers

Loris Bennett wrote at 2024-11-11 15:05 +0100:
>I have the following in my program:
> try:
> logging.config.fileConfig(args.config_file)
> config = configparser.ConfigParser()
> config.read(args.config_file)
> if args.verbose:
> print(f"Configuration file: {args.config_file}")
> except FileNotFoundError:
> print(f"Error: configuration file {args.config_file} not found. Exiting.")

Do not replace full error information (including a traceback)
with your own reduced error message.
If you omit your "try ... except FileNotFoundError`
(or start the `except` clause with a `raise`), you
will learn where in the code the exception has been raised
and likely as well what was not found (Python is quite good
with such error details).

> ...
>My questions are:
>
>1. Should I be surprised by this behaviour?

Your code contains a major weakness (see above); thus surprises
are not unlikely.

>2. In terms of generating a helpful error message, how should one
> distinguish between the config file not existing and the log file not
> existing?

You look at the error information provided by Python
(and its library) rather than hiding it.

Subject: Re: FileNotFoundError thrown due to (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 11 Nov 2024 21:05 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to (Posting On Python-List
Prohibited)
Date: Mon, 11 Nov 2024 21:05:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <vgtrim$15srv$5@dont-email.me>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 11 Nov 2024 22:05:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="13b7eac62ff6457352a541d5a235d1e2";
logging-data="1241983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pe+5akMOS66cS3wgVwBSE"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:bVXJX1jkSLZDNMDPRAi1Awh71e0=
View all headers

On Mon, 11 Nov 2024 15:05:56 +0100, Loris Bennett wrote:

> except FileNotFoundError:
> print(f"Error: configuration file {args.config_file} not found.
> Exiting.")
> sys.exit(0)
>
> and when I ran the program I got the error
>
> Error: configuration file /usr/local/etc/sc_mailer not found.
> Exiting.
>
> However, this file *does* exist and *can* be read.

This is your own fault for intercepting the exception and printing out
your own misleading error message. If you had left the exception uncaught,
it would have printed out the right file name.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Chris Angelico
Newsgroups: comp.lang.python
Date: Tue, 12 Nov 2024 01:17 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Tue, 12 Nov 2024 12:17:27 +1100
Lines: 11
Message-ID: <mailman.96.1731374262.4695.python-list@python.org>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de uf1AJP1hhGKjBAy4luMRBgNxJTpRqTLcca6B1LTta5rw==
Cancel-Lock: sha1:vJxI5fH8ds9Pv6vLjCo2TLQS0C0= sha256:l4HSRQ7FtDKPpbxw3Ds8kCI0zHdamg3cKRgOREpKt5g=
Return-Path: <rosuav@gmail.com>
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=gmail.com header.i=@gmail.com header.b=QJCBk7r6;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.025
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:name': 0.07;
'better,': 0.09; 'log': 0.12; 'assuming': 0.16; 'attributes':
0.16; 'bennett': 0.16; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'generating': 0.16; 'message?':
0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20; 'exception':
0.22; 'subject:file': 0.22; 'error': 0.29; 'tue,': 0.31; 'message-
id:@mail.gmail.com': 0.31; 'python-list': 0.32; 'path': 0.33;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.34; 'file': 0.38; 'should': 0.40;
'between': 0.63; 'your': 0.64; 'let': 0.65; 'terms': 0.69;
'received:mail-lj1-x22d.google.com': 0.69; 'subject: \n ': 0.84;
'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731374259; x=1731979059; darn=python.org;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=5sfcMfATOS0+4Xu0V3Jj2q/hNnXo235P4IKrnm+2+fE=;
b=QJCBk7r6AHXR5BEoZCHLRdDnZhkI2sv5PfqiDzrY5voNcUx7nBZl5ONz+yw/yQB8Fg
X/JOr9tY45Z9nSqrPSNZ+Y7+coNrSbb9nd2BWr/bpFCXmcAD4rcwWLoF5YMlS1dKU986
k/xNrLpHTOKnJWBPwT6nBLZhR+1Rz/9JEyD74zUv7pGwisB7AmD+lGi0/YyQwQw7AyVe
5sn+T+gKxpY6Av7+ghgJA7r/MbnZNPrbL39kIgOoGtFV309dh1uZApoTvIZYSEijaye6
OMVT94WFjMe6bKwxf9gVvysw86iScw3QpoGuMTvG8zlNGM0jJ1j5to6Cm8V+CTXMoQCH
q6IQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731374259; x=1731979059;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=5sfcMfATOS0+4Xu0V3Jj2q/hNnXo235P4IKrnm+2+fE=;
b=l33XcJOblubAaJ/jG/U1pHGtJbyJheSoeiQuSexT1fDIOcpLXsQ0crGdIxG1Dj0Rgt
pZje7j0/tMlXY0vueldWq5hKoX+aXOkWWbSQXtanmQ0e2DLkf9HRQ59tIMvJu6Ylwavv
7syNJS56byPHpA2+7Xxi7MJixglK/GaOFkJXVzqU4nGKH0Hj1XY38gKujzxpgmoeNjJU
vyH/bsXMccjrbt0khUduSdteWkvwb9O54j2jGT7QBID6z3645qDN2267cmEGmZdEijjm
wADGebGlOhg8f1wrCJ3/CpvixgqVdd6xFgC5lvVxcdBIi9NGp37e4gQY46wh65Z7iPw3
i8LA==
X-Gm-Message-State: AOJu0YwFkvxYuSJ2169UBuNEYtJ6drnEc6NYk39qJokd7qy2D73nGdv6
Y87sccue8giF0Gx4cz1oGsVPpdhmrl7c+JvXM92QJKTS/wkwq+D1fPhd8qpDOWD5fWk1PfEkCHa
qCleyv26QI22atwnA4Z61DUBSlZyYpQ==
X-Google-Smtp-Source: AGHT+IGYuIeiZ5adbgzcQxLfueaeh4pfJyejElFNrhXallj01zB/o9zaVmPDD7PyCJRV/CoV9BFHy7gvOojl7EK8I1g=
X-Received: by 2002:a2e:b895:0:b0:2fb:5035:7e4 with SMTP id
38308e7fff4ca-2ff20162842mr78675991fa.5.1731374259295; Mon, 11 Nov 2024
17:17:39 -0800 (PST)
In-Reply-To: <87v7wt986z.fsf@zedat.fu-berlin.de>
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: <CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de>
View all headers

On Tue, 12 Nov 2024 at 01:59, Loris Bennett via Python-list
<python-list@python.org> wrote:
> 2. In terms of generating a helpful error message, how should one
> distinguish between the config file not existing and the log file not
> existing?

By looking at the exception's attributes rather than assuming and
hard-coding the path in your message? Or, even better, just let the
exception bubble.

ChrisA

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Loris Bennett
Newsgroups: comp.lang.python
Organization: FUB-IT, Freie Universität Berlin
Date: Tue, 12 Nov 2024 09:00 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
Date: Tue, 12 Nov 2024 10:00:36 +0100
Organization: FUB-IT, Freie Universität Berlin
Lines: 25
Message-ID: <87h68cyggb.fsf@zedat.fu-berlin.de>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de R7dxPmMAs/9T59TEuCW75QH4YSBzg6xcnrJUYu4BZrAqH4
Cancel-Lock: sha1:j9rkfJCnGijcPkdYtfIKIOI70x8= sha1:e22JrwMQn7WHoGEUlWHsCJ/X+ts= sha256:3b2DWHZRa8KefRrJArJCoQpo4A9AdGq3yBT+tdq38Bw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
View all headers

Chris Angelico <rosuav@gmail.com> writes:

> On Tue, 12 Nov 2024 at 01:59, Loris Bennett via Python-list
> <python-list@python.org> wrote:
>> 2. In terms of generating a helpful error message, how should one
>> distinguish between the config file not existing and the log file not
>> existing?
>
> By looking at the exception's attributes rather than assuming and
> hard-coding the path in your message? Or, even better, just let the
> exception bubble.

As Dieter also pointed out, I obviously made a mistake in assuming that
I knew what 'FileNotFound' was referring to.

However, it strikes me as not immediately obvious that the logging file
must exist at this point. I can imagine a situation in which I want to
configure a default log file and create it if it missing.

Cheers,

Loris

--
This signature is currently under constuction.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Loris Bennett
Newsgroups: comp.lang.python
Organization: FUB-IT, Freie Universität Berlin
Date: Tue, 12 Nov 2024 09:03 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
Date: Tue, 12 Nov 2024 10:03:10 +0100
Organization: FUB-IT, Freie Universität Berlin
Lines: 18
Message-ID: <87a5e4ygc1.fsf@zedat.fu-berlin.de>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de gOehtvHKXYuZXTyzca9enwvWfAukXwUVDgr8Ui3fHPiGoD
Cancel-Lock: sha1:k/vcnI5AMQA+rgwn6gBBnahP+TU= sha1:Dcu0p2ooIs7PrAxu+z+WWGSMldQ= sha256:4f0IzUZEt6DcTO13uGsm5way6qps+KBZInUN/UAh/MI=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
View all headers

Chris Angelico <rosuav@gmail.com> writes:

> On Tue, 12 Nov 2024 at 01:59, Loris Bennett via Python-list
> <python-list@python.org> wrote:
>> 2. In terms of generating a helpful error message, how should one
>> distinguish between the config file not existing and the log file not
>> existing?
>
> By looking at the exception's attributes rather than assuming and
> hard-coding the path in your message? Or, even better, just let the
> exception bubble.

I didn't consider letting the exception bubble as is the top of the
code for a CLI program. I was hoping to just catch what I thought might
be a common error of the config file being missing.

--
This signature is currently under constuction.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Loris Bennett
Newsgroups: comp.lang.python
Organization: FUB-IT, Freie Universität Berlin
Date: Tue, 12 Nov 2024 09:15 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
Date: Tue, 12 Nov 2024 10:15:47 +0100
Organization: FUB-IT, Freie Universität Berlin
Lines: 100
Message-ID: <875xosyfr0.fsf@zedat.fu-berlin.de>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAJQBtg=UOiOmmHa25EUZtrZO19F1O0_VxCO6gWjZ5ebAMHnXCA@mail.gmail.com>
<mailman.92.1731341107.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de YxVcmas1QBIRwxDDtYVyUg2omyKenFjRGnfDjRXuSHJdfl
Cancel-Lock: sha1:UmDrsABNAtj8Nm1l3ljCv2aU7mM= sha1:v6OB/ZJq2bkLM+KZGv/VUUXlF6g= sha256:jlKoWppUUz6FfqG2IDlc6YMwJDyzAjUQeZGLHfAqK4c=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
View all headers

Left Right <olegsivokon@gmail.com> writes:

> Poor error reporting is a very common problem in programming. Python
> is not anything special in this case. Of course, it would've been
> better if the error reported what file wasn't found. But, usually
> these problems are stacking, like in your code. Unfortunately, it's
> your duty, as the language user, to anticipate those problems and act
> accordingly. Now you've learned that the one file you believe that
> could be the source for the error isn't the only one--well, adjust
> your code to differentiate between those two (and potentially other?)
> cases. There's very little else you can do beside that.
>
> NB. On the system level, the error has no information about what file
> wasn't found. It simply returns some numeric value (the famous
> ENOENT) in case when the system call to open a file fails. Python
> could've been more helpful by figuring out what path caused the
> problem and printing that in the error message, but it doesn't...
> That's why I, myself, never use the vanilla FileNotFoundError, I
> always re-rise it with a customized version that incorporates the
> information about the missing file in the error message.

That sounds like a good idea.

> NB2. It's always a bad idea to print logs to files. Any sysadmin /
> ops / infra person worth their salt will tell you that. The only
> place the logs should go to is the standard error. There are true and
> tried tools that can pick up logs from that point on, and do with them
> whatever your heart desires. That is, of course, unless you are
> creating system tools for universal log management (in which case, I'd
> question the choice of Python as a suitable language for such a task).
> Unfortunately, even though this has been common knowledge for decades,
> it's still elusive in the world of application development :|

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.

Cheers,

Loris

> On Mon, Nov 11, 2024 at 4:00 PM Loris Bennett via Python-list
> <python-list@python.org> wrote:
>>
>> Hi,
>>
>> I have the following in my program:
>>
>> try:
>> logging.config.fileConfig(args.config_file)
>> config = configparser.ConfigParser()
>> config.read(args.config_file)
>> if args.verbose:
>> print(f"Configuration file: {args.config_file}")
>> except FileNotFoundError:
>> print(f"Error: configuration file {args.config_file} not found. Exiting.")
>> sys.exit(0)
>>
>> and when I ran the program I got the error
>>
>> Error: configuration file /usr/local/etc/sc_mailer not found. Exiting.
>>
>> However, this file *does* exist and *can* be read. By checking the
>> 'filename' attribute of the exception I discovered that the problem was
>> the log file defined *in* the config file, namely
>>
>> [handler_fileHandler]
>> class=FileHandler
>> level=DEBUG
>> formatter=defaultFormatter
>> args=('/var/log/my_prog.log', 'a')
>>
>> This log file did not exist. The exception is thrown by
>>
>> logging.config.fileConfig(args.config_file)
>>
>> My questions are:
>>
>> 1. Should I be surprised by this behaviour?
>> 2. In terms of generating a helpful error message, how should one
>> distinguish between the config file not existing and the log file not
>> existing?
>>
>> Cheers,
>>
>> Loris
>>
>> --
>> This signature is currently under constuction.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
--
Dr. Loris Bennett (Herr/Mr)
FUB-IT, Freie Universität Berlin

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Left Right
Newsgroups: comp.lang.python
Date: Tue, 12 Nov 2024 19:10 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivokon@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Tue, 12 Nov 2024 20:10:55 +0100
Lines: 50
Message-ID: <mailman.100.1731438669.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>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de yHzNOJaFc+hvSZlDTRyNAQGdbH+IglpOA7LGTFyDMq7Q==
Cancel-Lock: sha1:kOUKOXuIOjk1rzKjcyZd+3Dc9IA= sha256:8FK4r66zy8U/13AqjZigqwMvlNLkPNnSXfc4J1SSye8=
Return-Path: <olegsivokon@gmail.com>
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=gmail.com header.i=@gmail.com header.b=heSYkq9U;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.032
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'debugging': 0.07;
'filter': 0.07; 'space,': 0.07; 'subject:name': 0.07; 'wrong.':
0.07; 'cc:addr:python-list': 0.09; 'fact,': 0.09; 'simplicity':
0.09; 'log': 0.12; 'cc:no real name:2**0': 0.14; 'that.': 0.15;
'aggregate': 0.16; 'category,': 0.16; 'command.': 0.16;
'database,': 0.16; 'impossible': 0.16; 'infra': 0.16; 'ldap':
0.16; 'logs': 0.16; 'moderately': 0.16; 'pipe': 0.16; 'received
:mail-qv1-xf34.google.com': 0.16; 'run,': 0.16; 'server,': 0.16;
'tries': 0.16; 'problem': 0.16; "aren't": 0.19; 'figure': 0.19;
'cc:addr:python.org': 0.20; 'option': 0.20; 'written': 0.22;
'first,': 0.22; 'subject:file': 0.22; 'anything': 0.25; 'past':
0.25; 'saying': 0.25; 'cc:2**0': 0.25; 'behavior': 0.26;
'perform': 0.26; 'output': 0.28; 'am,': 0.31; 'convention': 0.31;
'program,': 0.31; 'message-id:@mail.gmail.com': 0.31; 'program':
0.32; "doesn't": 0.32; 'but': 0.32; 'there': 0.33; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34; 'same': 0.34;
'mean': 0.34; 'from:addr:gmail.com': 0.34; 'files': 0.36;
'really': 0.36; 'cases': 0.36; 'work,': 0.36; 'source': 0.36;
'change': 0.36; 'those': 0.36; "it's": 0.37; 'file': 0.38; 'way':
0.38; 'both': 0.38; 'quite': 0.39; 'single': 0.39; 'enough': 0.39;
'advantage': 0.40; 'program.': 0.40; 'wants': 0.40; 'whenever':
0.40; 'want': 0.40; 'best': 0.61; 'remember': 0.61; "there's":
0.61; 'day,': 0.62; 'gives': 0.62; 'come': 0.62; 'send': 0.62;
'similar': 0.63; 'email': 0.63; 'your': 0.64; 'touch': 0.65;
'required': 0.65; 'that,': 0.68; 'during': 0.69; 'currently,':
0.69; 'drop': 0.69; 'natural': 0.69; 'care': 0.71; 'chance': 0.71;
'free': 0.71; 'low': 0.74; 'records': 0.75; 'heart': 0.76;
'potentially': 0.76; 'etc.,': 0.84; 'perspective,': 0.84;
'reliability': 0.84; 'subject: \n ': 0.84; 'property': 0.88;
'reliable.': 0.91; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731438667; x=1732043467; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=HEJuYe3uUafqppa6PXsUucqF14irQJE4I8n0swhaa7A=;
b=heSYkq9UxLykjOMUEkeUOXGxviqMJx4iYySl53urdeB7pjYN63qngQZKYBe64wTw+c
uhEMqKzE+fva+e+2HSc6SSJKjEUTp0FlnSSQjjFHhcsXCj5OGvj+vkTTXFf+CeevIko6
rL+bd1J2d6W2cQgTgfcP2MTsbeNRfu7eTcrZYStPxBMI8/BYsbp/1+U2Vvn//6LSdK0f
RKQxBAfmD++owBA9Gwi1qXCY2EgvEWkMDaLbGoxkYKy8kgZHCX3Fk0GC4O4ABFPYHoEG
obcdyxuPnE5BQpuYx4ugrh4UqobH41UMErW2SDYj+RV71LOzDraRBcrOwlAFmSsOpeA5
qn3g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731438667; x=1732043467;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=HEJuYe3uUafqppa6PXsUucqF14irQJE4I8n0swhaa7A=;
b=IJIWSkkc2u6e7MmRLtAZrB/tNyAFmApjRTcNJXnlTLuM12lDyg5KSn4PC6Aw7t8v2k
3yW7h4ewZp1BpnL4sYGey+zc+vZNZ9wkIB9hfE/XNkhW4BzdxPVBvoCqJQod84jewI0U
DH/BfsERFzMEmGAwOy16c5kdamLVLy6RV/qUxVmvjzoQInB6GWW5wqCDC+6pjHy/FS/D
oIUp7WvYmWKBgTtOuS+4cgDW/LcgKgsnpCOQiEOwsEUZG71p6fXxyD4OjG3Kw5s8PLu1
OkVu8eZ2IV5yhoEELgCRShy3HlXLxkWeoNGP7ePSurj3XS+oPPK/+X+CTpU9wfZGUmDu
f75A==
X-Gm-Message-State: AOJu0Yy0FjZdWK3fOhsrTuBM47jvAWYk0RkCcDr0gQFMOP+5z9V6kDPB
9czzdZeg9j0EjBrb6u/JLOSjDzfOnopCe5aqShlYrnUvsq/lpbE9pVg2n80DWorqW6p6V/WBzlV
k7QCWMkn70La2otGKrdZDRcgvEhwf2pKw
X-Google-Smtp-Source: AGHT+IEbCNGSFVA2mjGYJ1eGtYjgLvX+FJp/u/SvXhLtRKn3Y509ahGnxB03rj///ncdHdk8WJ6vBSkjdH3N6tdcov4=
X-Received: by 2002:a05:6214:4803:b0:6cc:364f:fc32 with SMTP id
6a1803df08f44-6d39e19639amr278599156d6.32.1731438666912; Tue, 12 Nov 2024
11:11:06 -0800 (PST)
In-Reply-To: <875xosyfr0.fsf@zedat.fu-berlin.de>
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: <CAJQBtg=nr+KC5iz_WY7nqkGK+YBEWAPq40ksaWJCAOT_+=pHxg@mail.gmail.com>
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>
View all headers

> 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.

There are similar reliability problems with writing to Unix or
Internet sockets, databases etc. For different reasons, but at the
end of the day, whoever wants logs, they want them to be reliable.
Both simplicity and convention selected for stderr as the only and the
best source of logging output.

Programs that write their output to log files will always irritate
their users because users will have to do some detective work to
figure out where those files are, and in some cases they will have to
do administrative works to make sure that the location where the
program wants to store the log files is accessible, has enough free
space, is speedy enough etc. So, from the ops perspective, whenever I
come across a program that tries to write logs to anything other than
stderr, I make an earnest effort to throw that program into the gutter
and never touch it again. It's too much headache to babysit every
such program, to remember the location of the log files of every such
program, the required permissions, to provision storage. If you are
in that line of work, you just want all logs to go to the same place
(journal), where you can later filter / aggregate / correlate and
perform other BI tasks as your heart desires.

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.

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. So, really, there aren't any
excuses to do that.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Mats Wichmann
Newsgroups: comp.lang.python
Date: Tue, 12 Nov 2024 20:28 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: mats@wichmann.us (Mats Wichmann)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Tue, 12 Nov 2024 13:28:04 -0700
Lines: 11
Message-ID: <mailman.101.1731443290.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>
<f60479e0-b3a9-487e-9625-804d4aab26bf@wichmann.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de cNTBiXMglcID8w6d/WG/9gAlzvpfa69Ck311JujGTJBQ==
Cancel-Lock: sha1:2Hx9vToKloKIiXesginsNfVf/dc= sha256:WoCSBm+HTp2krkAYNqNuneXRbu1tTrxRzMfNLeKtQnE=
Return-Path: <mats@wichmann.us>
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=messagingengine.com header.i=@messagingengine.com
header.b=f0p+PmSB; dkim-adsp=none (unprotected policy);
dkim-atps=neutral
X-Spam-Status: OK 0.105
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.80; '*S*': 0.01; 'subject:name': 0.07;
'that.': 0.15; 'logs': 0.16; 'received:10.202': 0.16;
'received:10.202.2': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'wrote:': 0.16; "aren't":
0.19; 'to:addr:python-list': 0.20; 'option': 0.20; 'subject:file':
0.22; 'run': 0.23; 'header:User-Agent:1': 0.30; 'python-list':
0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'really': 0.36;
'way': 0.38; 'want': 0.40; 'helps': 0.60; 'gives': 0.62; 'your':
0.64; 'thus': 0.64; 'right': 0.68; 'currently,': 0.69;
'received:202': 0.69; 'left': 0.83; 'subject: \n ': 0.84;
'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wichmann.us; 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=2018-07.pbsmtp; t=
1731443286; x=1731529686; bh=a+aCJ4lKCkJP8ADFRSWxFF9WnlVZDu+20hX
TQ1kslA4=; b=F2iDx3sg0hE1dEIJekRAnrGNJmZtvmfpVDUdcDaw9/KVJ0lN2ZL
iJH4npa0wGnVyljooeVrErcQ4pZDCpNgeEbNzuFq9cRE2RPZU5P+k8nzX5px8jmC
kVlXrFx2r1EgNr9zaB0x0fvCaON6gjVfKB6EgE8PpAwRTilCpGu7Q4Gg=
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=1731443286; x=1731529686; bh=a
+aCJ4lKCkJP8ADFRSWxFF9WnlVZDu+20hXTQ1kslA4=; b=f0p+PmSBo0Oox0r9E
FZE8LBR7gyczruEBhFYX2eeVhurhPV7FwrLhkTDeBBvpWpNg5d9xA8I/M5xp3283
Bw52RcQy+aJXK9DpMkhI4gphULyqXK4LejqvADzljx6CkuSYHBONKtFi3WCLA911
nMxXFIfCzeX3ihvdItPY5O0p83i8k1K4hEGqrQ7IWAmh1ttM+iChFIE50CWL0Rzy
RO/smUjPN1nlwGX44i5dUVMu7uGFDmQ1DWqD4dcRpRQdps96FraijTci3FVcXeSS
aB1P9bVgcZ2djGz79vQS/PJ8BgEHwwVJorcEZ9p+dC1ufvdU3pZiJHDUei3/wxnd
i7eHw==
X-ME-Sender: <xms:VrozZ7sSIbeZANR0-46_ssr9D4kf5wPJvPk_XQfmEiCNHyV26zs_lQ>
<xme:VrozZ8cXQ2aSAnWt1A1lWLPb-S4yqsP-JwgqTeDn8BX7mq2WYDo8FONl3JzTNHFCR
2ehL2IflBvPxL0VLak>
X-ME-Received: <xmr:VrozZ-xBwkaK-klqvXzGuB1BxDXEWc3L0X1ZchSYGLtMI1Y-7chzMFktpnPyOZ3WxNABq1-hQxIql05UFxDDrbfg5wB_cMav3Q>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeggddufeefucetufdoteggodetrfdotf
fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfg
fuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeforghtshcuhghitghhmhgrnhhn
uceomhgrthhsseifihgthhhmrghnnhdruhhsqeenucggtffrrghtthgvrhhnpedtjeduve
eiteegteejgeehiedufeekgfdvjefgvedtteduffeuieelieevtdegffenucevlhhushht
vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrghtshesfihitghhmh
grnhhnrdhushdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghp
thhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
X-ME-Proxy: <xmx:VrozZ6OFY1o0o0UOArNI3kFkCBpbq3_nIKwll3pIKJ7Ng4DeprTEXA>
<xmx:VrozZ78c-K60HhvKkkptDEWS29njKanoR1kO67kMYpBHiaagV8NC_Q>
<xmx:VrozZ6VzcgyAyg2Jfkuq1ao2dBKZj9ggtO74Q93sudtPGMPKOMctIw>
<xmx:VrozZ8cMW0VqcaW8O9RIkmrgkTP1DY5RDN3fx-U4tJX32M3ebW6v8g>
<xmx:VrozZ4EwZQm_hf36W48_C4rsNIeNZq3Cg8J4HQJ0gG_6MXNwkYBY1hxu>
Feedback-ID: i387144f0:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Autocrypt: addr=mats@wichmann.us; keydata=
xsDiBD9xp6oRBAC1vd3YI8Gcr1CxpV1gldNQu0uQsNaICDk+Ai3+R163s/P83JOYG+SBEA3P
v7iZx70qpQ3RzP7KrjF1Nm6j0em9ccUX2fPQUCAxXw5Hiq7CSMiwQQZRI6shcnyMh9XTKViT
WK5MrKDyvjDEn7epjKzKwPS5SG039l6XaOKU0A4uGwCgsNqUQqC0gMMcbKlJV8ql58iKmbMD
/ii8FPQrXmyS/FnsPs7UddV5qMHKm7NUH5oiKuMVyakInRyq9iIxuu3D4Ec6mWRKcGsjmIkW
HXCSz0aefs6dsqNqpU54cYioJ3wP5LzHK7oclgJPryVt5Qezbdutf8SQf8gVkaNIlkxwGUzi
bKTZ6CHzwlz9nNgeel0XPUcZzFxGA/4paeCg2rMSVuAhUQbsLYHu4XzTs9P16zaXkrtxc4m5
b+BF5xsLgTpyO5l859XudS2Gp+7/Y37dAU4QlyGGOboWmF1y9U5DnzBwG8ghsnym+ga58MJh
LdRdQQ6xQolCpEXOuzm40f2r5uMxF3KOJ7WpIPuGAkeCPru9BmlATH+zOs0gTWF0cyBXaWNo
bWFubiA8bWF0c0B3aWNobWFubi51cz7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX
gAUCT0VyZwIZAQAKCRDAMaCQc9hUxiZBAJ9cWziGp7hVfsu5T+cQptc3rLNndQCgrZh8u5LW
BfJ5e/Y+3PwZ8UEm+ELOwE0EP5is8BAEAMtwzcA8TYf5UTjDMgwcSNoErTc9ag+IX05QFgL8
aF8sfJRv5atcitqQy0gSIsOzI+L/AFdPN/+QQI3dL1tCq14t32KPDtigDhzm6jVPXX5z+V9u
xnD8XTp+ZvNcWoHXjViM8aXeLLEiCpiVCho307h3XShvqoKINWRQWeAsKKDDAAMFA/48zaey
wiiEyvI0meJ1KkNHxdLP0yLODr1WV6j9xkPkLWOaIDw7dlwEOlF1N1YtZ2wa0p1wsttdIbIx
ffgwXmcH4zrdxUIMz3U0BqYzk5H+5cYFXECXTFVOmweS+JECYMj80PjRoKCO1eVO1N30zksB
36NnhZWPRWIhjK3ZarIYH8JGBBgRAgAGBQI/mKzwAAoJEMAxoJBz2FTG6VEAoKDYHfDp5Q3q
PuPvPahCE9HsXMgAAJ9INTqcLSJrOfyJ8q95nBO1T26H2Q==
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: <f60479e0-b3a9-487e-9625-804d4aab26bf@wichmann.us>
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>
View all headers

On 11/12/24 12:10, Left Right via Python-list wrote:

> 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. So, really, there aren't any
> excuses to do that.

an awful lot of the programs that need to do extensive logging don't run
under control of a shell, and thus "shell redirection" helps not at all.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Chris Angelico
Newsgroups: comp.lang.python
Date: Tue, 12 Nov 2024 20:34 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Wed, 13 Nov 2024 07:34:10 +1100
Lines: 18
Message-ID: <mailman.102.1731443664.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>
<f60479e0-b3a9-487e-9625-804d4aab26bf@wichmann.us>
<CAPTjJmpTngd26KUymwbi6LJn1yunCEpwMbZRT11Bi1=S2nuR-g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de b4a8c9aT8nx6Ys8RXF4cDwHKhSGJ6wV18S74FKpr9DAw==
Cancel-Lock: sha1:vNSmjbf52M4DHJiG5XK6Xe3sGQY= sha256:nDLk7lBqG5fEqsD1V4jpvGLghSUdRLI2Lef4EAqRJqw=
Return-Path: <rosuav@gmail.com>
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=gmail.com header.i=@gmail.com header.b=gvewShVd;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:name': 0.07;
'thing.': 0.07; 'cc:addr:python-list': 0.09; 'cc:no real
name:2**0': 0.14; 'syntax': 0.15; 'that.': 0.15; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'logs': 0.16; 'mats': 0.16; 'received:mail-lj1-x22a.google.com':
0.16; 'to:name:mats wichmann': 0.16; 'wichmann': 0.16; 'wrote:':
0.16; "aren't": 0.19; 'cc:addr:python.org': 0.20; 'option': 0.20;
'subject:file': 0.22; 'run': 0.23; 'cc:2**0': 0.25; 'message-
id:@mail.gmail.com': 0.31; 'python-list': 0.32; 'there': 0.33;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.34; 'request': 0.35; 'really': 0.36;
'way': 0.38; 'wed,': 0.39; 'still': 0.40; 'want': 0.40; 'helps':
0.60; 'gives': 0.62; 'your': 0.64; 'thus': 0.64; 'right': 0.68;
'currently,': 0.69; 'left': 0.83; 'subject: \n ': 0.84;
'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731443662; x=1732048462; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=8WdyZs0/wBJoX6vWw/ZdAlamNKnxLgydHCpTmd0dl0o=;
b=gvewShVd0nwGT5CPxupcLva3SOTDUQQqfbii7YHkJ3NFp6xWQj5LODKHk0P6p2Q+0a
iqUVUYzpv6PFwaEM7UL/rA9QltSCHujrcXJ29y2LXeNATEz9lFN5jxOMG9+PpMZT2FVk
x6sNkrkQ9z+Eu9NPkGKbQEtsrjWNblZZAR3i/4wjmkUnEkxjWusNhc07bSHbt611Z+w7
+O9S5ppKTPEyvP8PTnMmYRqJv8b+/H/NtLKnFAk3M/0h6pUvHyeqwYAdHXhB4Pcs4Ee7
1x2ouO7MCxirLOe+aG9UdL3IlcmVxpQvj9m4MvokoYTRl5s39bHWIGU5mQi2OxtxLqYb
8yGg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731443662; x=1732048462;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=8WdyZs0/wBJoX6vWw/ZdAlamNKnxLgydHCpTmd0dl0o=;
b=ikHfKJcGLXSj4taJO015gS0vqnfMhtqdDD215GKtBCAoNho7CV3qD+mSwmQB0RQAQ4
VihDzlPmF2C4BJJH+CpWf/RBPQ+0csSTs3IxEoWuYQ53DVHEqJihpy2XAtvowuunPROo
5hM5vMNA1oDY5B6ZQ/lLNpPXmGY0ZF1xyDE4ve14hbM4Z7PBHAd0uT32OYUwR+tJHJFF
uY8qzYwyCcAbfBu/NaqnWM1Ozhqy1xzzQxOQJu9E5f7SEz5YDBzSjuVA6P5zl7MLFjDW
8KJNSa98TkYzNDVBdIdVW+YV3fRc2i0Oz6SY5n6cbtUNumPaEZV58KnKxAO/9i/dwytc
F7Wg==
X-Gm-Message-State: AOJu0Yzoqb/RhZJBIpjVLrXcJikBWriuENPWhFz73W9XMg+O+z5sSGcB
sZyFS/NZPD/taKvWlZtudPcwhjU890ttItRhJLEFTSIkEg+U54T5Knoq4op12sFg39Znm8O12h+
VVixlBJvD2XQTCMbGzMBotyhEtVO8hw==
X-Google-Smtp-Source: AGHT+IHVYojzctLUrpUWtjR0oogleLheOeoC04T5clQkDPWePGrqcKDujD37+E1fpFNBVhYgbh4y8ET0YJVrGqvOXxk=
X-Received: by 2002:a05:651c:2102:b0:2fb:6057:e695 with SMTP id
38308e7fff4ca-2ff2016d6e0mr97405861fa.18.1731443662027; Tue, 12 Nov 2024
12:34:22 -0800 (PST)
In-Reply-To: <f60479e0-b3a9-487e-9625-804d4aab26bf@wichmann.us>
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: <CAPTjJmpTngd26KUymwbi6LJn1yunCEpwMbZRT11Bi1=S2nuR-g@mail.gmail.com>
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>
<f60479e0-b3a9-487e-9625-804d4aab26bf@wichmann.us>
View all headers

On Wed, 13 Nov 2024 at 07:29, Mats Wichmann via Python-list
<python-list@python.org> wrote:
>
> On 11/12/24 12:10, Left Right via Python-list wrote:
>
> > 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. So, really, there aren't any
> > excuses to do that.
>
> an awful lot of the programs that need to do extensive logging don't run
> under control of a shell, and thus "shell redirection" helps not at all.
>

Redirection's still a thing. "Shell redirection" is just the shell
syntax to request redirection.

ChrisA

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Wed, 13 Nov 2024 01:04 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Wed, 13 Nov 2024 14:04:33 +1300
Lines: 24
Message-ID: <lpic93Fi985U1@mid.individual.net>
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>
<mailman.100.1731438669.4695.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net FJcy8cdT/tSFSD7dtEs2bwz++vxKSxTPMJnh17zG9M7Wa3G1Xv
Cancel-Lock: sha1:67mLfCUnxKZ8kx54kKVTB/jGjXI= sha256:4uCO2hVul/34eWiqaPRVng9jbIpktEStSF9jSKpRtAU=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <mailman.100.1731438669.4695.python-list@python.org>
View all headers

On 13/11/24 8:10 am, Left Right wrote:
> since logs are designed to grow indefinitely, the natural
> response to this design property is log rotation.

I don't see how writing logs to stderr solves that problem in any way.
Whatever stderr is sent to still has a potentially unlimited amount
of data to deal with.

> 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.

Not sure I follow you there. You seem to be thinking of a particular
way of rotating log files, where an external process tries to swap
the program's log file out from under it without its knowledge. That
could be vulnerable to race conditions. But if the program doing the
logging handles the rotation itself, there's no reason it has to
lose data.

--
Greg

Subject: Re: FileNotFoundError thrown due to (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 13 Nov 2024 02:13 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to (Posting On Python-List
Prohibited)
Date: Wed, 13 Nov 2024 02:13:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <vh11vn$1snqg$2@dont-email.me>
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>
<mailman.100.1731438669.4695.python-list@python.org>
<lpic93Fi985U1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 13 Nov 2024 03:13:11 +0100 (CET)
Injection-Info: dont-email.me; posting-host="0a06367de58bbdcfdc9005596a5fcaaa";
logging-data="1990480"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+owOtWyfzvY6ZCg2Auih44"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:+HNIAYyGx4p/9YUWzG1h/4oKZik=
View all headers

On Wed, 13 Nov 2024 14:04:33 +1300, Greg Ewing wrote:

> You seem to be thinking of a particular way
> of rotating log files, where an external process tries to swap the
> program's log file out from under it without its knowledge. That could
> be vulnerable to race conditions.

But if you just use standard system facilities, like syslog or the systemd
journal, that is automatically handled for you.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Loris Bennett
Newsgroups: comp.lang.python
Organization: FUB-IT, Freie Universität Berlin
Date: Wed, 13 Nov 2024 07:11 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
Date: Wed, 13 Nov 2024 08:11:01 +0100
Organization: FUB-IT, Freie Universität Berlin
Lines: 92
Message-ID: <87iksrehh6.fsf@zedat.fu-berlin.de>
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>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de 3gnffweF3a7ts/fUO/sfOQCsSheBFFd1hronvKqdr+fUQd
Cancel-Lock: sha1:0xBpLLLZUpBgPSgW9VbJ6AjyMX8= sha1:+C/K0R32soqOEM/RfrFObzCs4YY= sha256:6BRSsbiRwLLHQ4dsuQ0e00liQBwXBd2yyo1CcQ90WqE=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
View all headers

Left Right <olegsivokon@gmail.com> writes:

>> 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.

> There are similar reliability problems with writing to Unix or
> Internet sockets, databases etc. For different reasons, but at the
> end of the day, whoever wants logs, they want them to be reliable.
> Both simplicity and convention selected for stderr as the only and the
> best source of logging output.

If I understand correctly you are not saying that logrotate is less
reliable that the other methods mentioned above. But in that case,
reliability seems no more of a reason not to log to files than it is a
reason not to write to a socket or to a database.

> Programs that write their output to log files will always irritate
> their users because users will have to do some detective work to
> figure out where those files are, and in some cases they will have to
> do administrative works to make sure that the location where the
> program wants to store the log files is accessible, has enough free
> space, is speedy enough etc.

All your points regarding the work involved are valid, but many
programs, such as MariaDB, OpenLDAP or SSSD, do write to a log file (and
it is usually under /var/log or /var/log/something. So it seems like a
common approach.

Besides, I define the location of the logfile in the config file for the
program (the problem in my original question arose from this filename in
the config file not existing). So finding the location is not an issue.
You have to find the config file, of course, but I think /etc or
/usr/local/etc are fairly standard and my programs generally have an
option '--config-file' anyway.

> So, from the ops perspective, whenever I
> come across a program that tries to write logs to anything other than
> stderr, I make an earnest effort to throw that program into the gutter
> and never touch it again. It's too much headache to babysit every
> such program, to remember the location of the log files of every such
> program, the required permissions, to provision storage. If you are
> in that line of work, you just want all logs to go to the same place
> (journal), where you can later filter / aggregate / correlate and
> perform other BI tasks as your heart desires.

That may be true in many cases, but those I am dealing with don't
require much filtering beyond 'grep' and also don't require aggregation
or correlation.

> 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.

What I do is indeed a bit of a niche, but I do get paid for this, so I
would not consider myself a 'hobby enthusiast'.

> 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. So, really, there aren't any
> excuses to do that.

I don't quite understand what your suggestion is. Do you mean that I
should log to stderr and then run my program as

my_program ... 2>&1 | logger

?

Cheers,

Loris

--
This signature is currently under constuction.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Roel Schroeven
Newsgroups: comp.lang.python
Date: Wed, 13 Nov 2024 09:12 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
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>
View all headers

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

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: dieter.maurer@online.de
Newsgroups: comp.lang.python
Date: Wed, 13 Nov 2024 18:36 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: dieter.maurer@online.de
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file,
rather than file itself
Date: Wed, 13 Nov 2024 19:36:04 +0100
Lines: 14
Message-ID: <mailman.105.1731522974.4695.python-list@python.org>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
<87h68cyggb.fsf@zedat.fu-berlin.de>
<26420.61844.597011.839900@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de wrdh6G9Gxn1VbyT8ZFvVTQCgcvrhNITorSXmtJovzg5g==
Cancel-Lock: sha1:BueLIon+tEd81GN43L/4bHtPYlw= sha256:fiO/1tGQwZY0phKZbaTGCIQkfNU2rsF0enQfeXna9AY=
Return-Path: <dieter.maurer@online.de>
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=online.de header.i=dieter.maurer@online.de
header.b=CLdRzBbr; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.047
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'received:212.227': 0.07;
'subject:name': 0.07; 'cc:addr:python-list': 0.09; 'skip:` 10':
0.09; 'subject:, \n ': 0.09; 'log': 0.12; 'cc:no real name:2**0':
0.14; 'bennett': 0.16; 'exception.': 0.16; 'cc:addr:python.org':
0.20; 'exception': 0.22; 'subject:file': 0.22; 'received:de':
0.23; 'cc:2**0': 0.25; 'default': 0.31;
'received:kundenserver.de': 0.32; 'received:mout.kundenserver.de':
0.32; 'header:In-Reply-To:1': 0.34; 'really': 0.36; '...': 0.37;
'missing': 0.37; 'directory': 0.37; 'received:192.168': 0.37;
'file': 0.38; 'wrote': 0.39; 'situation': 0.40; 'want': 0.40;
'should': 0.40; 'tell': 0.60; 'mode': 0.62; 'point.': 0.62;
'imagine': 0.64; 'look': 0.65; 'obvious': 0.69; 'happens': 0.84;
'thus,': 0.84; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=online.de;
s=s42582890; t=1731522965; x=1732127765; i=dieter.maurer@online.de;
bh=6SqFR+Jf2vIOCfqUCjEPHycY5I7RksnNLorv25o+hTA=;
h=X-UI-Sender-Class:MIME-Version:Content-Type:
Content-Transfer-Encoding:Message-ID:Date:From:To:Cc:Subject:
In-Reply-To:References:cc:content-transfer-encoding:content-type:
date:from:message-id:mime-version:reply-to:subject:to;
b=CLdRzBbr3BLHwXrkvVDn9dQGFRtRzVBQLcBV0XD/uYXsWGupxd//WZf+tISyS9tG
MxOU5VYxTkOJ5fPbk/cQJkquQpv7WxkUxL7GnBZdAOpSAnOazflSIBte261GqwtN1
eWwd8gLWQeokdcopfJiy02O2XPPbihIzGubE6KuFl5tCKu6VXZZfWnPdirZltdi1l
ji7a6Y10tUhzs86Jlyx494973nW5dFDk2H8FwEcBzy2qXRZrTGOPIjhxW0gPQWTFc
B1ABFGglh80zd1bcHAPBUStXjurPugwYULS1KWRmVMeFsUCsJkHjSU7NLrYKzu+2s
0Vj+VrL3AzkWjrEpog==
X-UI-Sender-Class: 6003b46c-3fee-4677-9b8b-2b628d989298
In-Reply-To: <87h68cyggb.fsf@zedat.fu-berlin.de>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-Provags-ID: V03:K1:frY4DMevQOr8HqMCOv7gt0SnXNYbTsEzUfsA/k99QfhnMPXISIl
WJUqibuSifu4SyQnDIXve1GV+1PFMPo8cfizRx/GInqhUjOsZXr7sOksA/qdNgiwzMHARV3
2cShuOfhqKcLdD6WXHyUc9qQOSwbQOvZ74d9HCimJ6O7yLGKLa/4uq1h5Gz6Haji34Qzn6d
EFmrvX+pRxVi7QJMU0peQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:MLI+75rvP6I=;/84c1uW+vPB/PAp3+c0mQOD8RHS
I6RKcl+UQ+Lsw2lwJqS8xIwO5UgSo53oQPRiRIyNDWv6Rjghner6CTe18wl1js2OwUck2eXyx
BNTFGBv0EYm737RU+fE7lCjdsQcdkPBbfKkpCfGMTeH2UHCok2FOUZkdfE5Hl9ZcC0uIfgfmR
LGdUGOKy1yxhRRvErLwa78PXB8t8wY4u0FW6fWGB33MmA+O+TTJPVKf/Py3wJ6l/jS645e1g4
/wRUxNTrMm5DHsRM25voev0RYM7jkPLQUrpI1jRWZjKWzG0cjmaarYvknTiNcqh2k8ucclbpy
54z/1TZCeFMpP6YeBlNHQ8w9Xa3lsW74ooes0G1GvzSKOX/98Q3wg7xM/+vmkhkfq/YOCWut8
xR9ffn4u17tRC2QmcudJ6B7kXW8CgrQHGjhsz4gNE1bGErjfxFHmA4OOyZMhZa115SQxC6b9r
G+xmQZCgCR0aUB33+qaVht7h0t1c0a8pkdjkgyrf1LBLjO8RdoQwbCFYDIqrPmjtkdQmVaYu4
m6saKscsXVn2uidQSlFLKPRb6siMdEI3rfXnVYE3havACMtfdSzL2H/XnuD+WoLw77WomVP6J
TKlAugr865SS13jvDrvX3+JD3RbI53Ff4fbcNfdFkdIwFNu9VtkOlSyGDoMFDSbtEnetxTZWA
9Zx6ijMG693tAbE7yIbbz7DV4+8qHMlDUS+llRefREjIT8xMGNy9P5IidGvAHrr9mxGC3ltS7
88dKTJvrW/1hj55YEdLDiN6lJ2HNMsMPWdYJJtfOGOoBPt2+mZajLT8mXTJkKKV3KVsb7eeoC
13E64696q33zhsMGE0Iqic5aVL/40LQPXJXrU1ftBLHaaza3GJdKAbddzeKGy0qUrn
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: <26420.61844.597011.839900@ixdm.fritz.box>
X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
<87h68cyggb.fsf@zedat.fu-berlin.de>
View all headers

Loris Bennett wrote at 2024-11-12 10:00 +0100:
> ...
>However, it strikes me as not immediately obvious that the logging file
>must exist at this point. I can imagine a situation in which I want to
>configure a default log file and create it if it missing.

This is what happens usually:
if you open a file with mode `a` or `w`, the file is created
if it does not yet exist.

Thus, a missing log file should not give you the `FileNotFound`
exception.
Look at the exception details: they should tell you what really
was not found (maybe the directory for the logfile).

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Kushal Kumaran
Newsgroups: comp.lang.python
Date: Wed, 13 Nov 2024 22:40 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: kushal@locationd.net (Kushal Kumaran)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Wed, 13 Nov 2024 14:40:57 -0800
Lines: 21
Message-ID: <mailman.106.1731538158.4695.python-list@python.org>
References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
<87h68cyggb.fsf@zedat.fu-berlin.de>
<26420.61844.597011.839900@ixdm.fritz.box> <87msi2eozq.fsf@copper>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de yu3mCIpcsUHoRdWFBnlEsgxwTANrNW8hRYJD5SiyFJjg==
Cancel-Lock: sha1:2o/Qy7yHeHPdYNAKuUtOWzX+VI0= sha256:M80SjFuHulEHAkFt3wZCyJ+P0O7+M/sMO7P91vOddks=
Return-Path: <kushal@locationd.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=locationd.net header.i=@locationd.net header.b=HhPtFabg;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.138
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.73; '*S*': 0.01; 'subject:name': 0.07;
'skip:` 10': 0.09; 'log': 0.12; 'bennett': 0.16; 'exception.':
0.16; 'kushal': 0.16; 'wrote:': 0.16; 'pm,': 0.19; 'to:addr
:python-list': 0.20; 'exception': 0.22; 'subject:file': 0.22;
'header:User-Agent:1': 0.30; 'default': 0.31; 'path': 0.33;
'header:In-Reply-To:1': 0.34; 'really': 0.36; '...': 0.37;
'missing': 0.37; 'directory': 0.37; 'file': 0.38; 'wed,': 0.39;
'wrote': 0.39; 'situation': 0.40; 'want': 0.40; 'should': 0.40;
'tell': 0.60; 'mode': 0.62; 'point.': 0.62; 'imagine': 0.64;
'look': 0.65; 'obvious': 0.69; 'happens': 0.84; 'subject: \n ':
0.84; 'thus,': 0.84; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=locationd.net; s=s1;
t=1731537660; bh=GCVHkkneppy8N+epHzOnIUoKSwNqEbwywwxNW2yPaYQ=;
h=From:To:Subject:References:Date:In-Reply-To:From;
b=HhPtFabgs5mm0UdnfVVuEWHAW8LdEvP9f8wdqPJhsg8t/4CaxSfbOqNzfCxmgq6P2
g1UZMTLsQmK+9IJ6FIVTuPQLjJYsrU+0k0wME/PO5SZap+F3Kh8Et1pmC7lwwvzAor
uncsy5UoHGG+xRbEvQJ/VTphORcknWADeV+R+/DIKsd6V7ogck4umq/2DqqmClaids
Q0PWAp905h151zr218KIaNzDGaHLF1sTsG1J5E24i7Nm4p4qe3BBlaSjVl5L0AROOS
IqFo1/UNOJVbcGJpNujqD8vOQAmSzQ5GCoU+d6sty4rXEvwJCuiNjJaEtc0Y3Eb3yd
67HS0ZV+aFs2g==
X-Clacks-Overhead: GNU Terry Pratchett
In-Reply-To: <26420.61844.597011.839900@ixdm.fritz.box> (dieter maurer's
message of "Wed, 13 Nov 2024 19:36:04 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
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: <87msi2eozq.fsf@copper>
X-Mailman-Original-References: <87v7wt986z.fsf@zedat.fu-berlin.de>
<CAPTjJmoJErFTE-oS2X_Z+2yC6bMXvHZi0=CxkGhWnVtd4Gacvw@mail.gmail.com>
<mailman.96.1731374262.4695.python-list@python.org>
<87h68cyggb.fsf@zedat.fu-berlin.de>
<26420.61844.597011.839900@ixdm.fritz.box>
View all headers

On Wed, Nov 13 2024 at 07:36:04 PM, dieter.maurer@online.de wrote:
> Loris Bennett wrote at 2024-11-12 10:00 +0100:
>> ...
>>However, it strikes me as not immediately obvious that the logging file
>>must exist at this point. I can imagine a situation in which I want to
>>configure a default log file and create it if it missing.
>
> This is what happens usually:
> if you open a file with mode `a` or `w`, the file is created
> if it does not yet exist.
>
> Thus, a missing log file should not give you the `FileNotFound`
> exception.
> Look at the exception details: they should tell you what really
> was not found (maybe the directory for the logfile).

It is possible a directory along the path does not exist.

--
regards,
kushal

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Michael Torrie
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 04:07 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: torriem@gmail.com (Michael Torrie)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Wed, 13 Nov 2024 21:07:56 -0700
Lines: 14
Message-ID: <mailman.107.1731557282.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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de sz5sV03LZXBaEBGYetHliw53jc+MXh9X2oqo8F6YEu4Q==
Cancel-Lock: sha1:xZHzGoDFXqgaAA+5kqbVBO5TBVE= sha256:Wz7VgZMvtue5K1LpguOjIQo8XCJ+EPPqhvCMuLNurjg=
Return-Path: <torriem@gmail.com>
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=gmail.com header.i=@gmail.com header.b=RNtThniD;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.109
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.79; '*S*': 0.01; 'subject:name': 0.07;
'received:mail-pg1-x52c.google.com': 0.09; 'log': 0.12;
'impossible': 0.16; 'logs': 0.16; 'simple:': 0.16; 'windows.':
0.16; 'wrote:': 0.16; 'message-id:@gmail.com': 0.18; 'pm,': 0.19;
'to:addr:python-list': 0.20; 'written': 0.22; 'subject:file':
0.22; 'past': 0.25; 'header:User-Agent:1': 0.30; 'python-list':
0.32; 'signal': 0.32; 'but': 0.32; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.34; 'one.':
0.35; 'close': 0.35; "it's": 0.37; 'received:192.168': 0.37;
'file': 0.38; 'quite': 0.39; 'handle': 0.39; 'happen': 0.40;
"there's": 0.61; 'send': 0.62; 'simply': 0.63; 'right': 0.68;
'during': 0.69; 'chance': 0.71; 'left': 0.83; 'rotating': 0.84;
'subject: \n ': 0.84; 'reliable.': 0.91; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731557279; x=1732162079; darn=python.org;
h=content-transfer-encoding:in-reply-to:from:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:to:cc:subject:date:message-id:reply-to;
bh=+hWQaPinlloV01tJY2h1GhNJLvCff/UZbq3+hNkHPsg=;
b=RNtThniDzivB75eTEtNf6i1UEh+el2XELe19CagZ4ypfN2qHGPEMdyOwA0YTYk3Mje
TKzVEKIUxHC/gUidgUybicnsSjopkFNSEWjzdSlka460rM6f5XTaw+ZAy38bWNfz2LyJ
Ob4T7FMK8uaRxe/z7ClzAfQTi02vuZlkyT1O1UpYwBPDtQgj1gjhw1aRgH0GSpxNBEt/
6nW0F9Vo1GVEMPb4aNInhwFVSjCbBnxI/lYhNQXwbDk83olB/kBXNrYq59JzxLscgfYC
LYiaCUzfpxtqhbkAt9dYjBRE4PH65c3ipf6O2wmq2zvTL0olHaJjdU9/PHtrX1PQFyQt
Rdmg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731557279; x=1732162079;
h=content-transfer-encoding:in-reply-to:from:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=+hWQaPinlloV01tJY2h1GhNJLvCff/UZbq3+hNkHPsg=;
b=WKEEB4U3fSCZhq28Qxd3WqI/ydFyV06VgM5E4KYTVxd3cCWGHd8kQiue0mP27YrLw1
facUYBZYGczu9jUWJg6P0/Az6iR0Kv0dGkUskS0pDKGwgqvrwQVIbZzl7nQgoqW8E9DL
R4JMav+S3xalyTKds+a16iYfEeLlPh29DtLg+R+rXYN6+YjsP0P4aXuA4YvH1iNWdSTk
7IQzCVSJQFPf08XR0Heb4umpggjTF8u0KxdbXnHlMWZ2zoYYWRh+zq5GhV9OWAG3MUI8
u9kucL3T3ILRvIkqoEUtCvMArcRzbwVQR/Un2bo+i6c+domz7U6Nvwj/qMm7pmwcCxbx
r8bw==
X-Gm-Message-State: AOJu0Ywn7w41yv64hchxha+tQU0Wmi45oPkFIWyuUzWfhpxhWtvuY2Np
V3bLheJtlC6avGHPBy0BA6xsG6SJko7xalNr2op8L/CCXIUt2m+Ky18IsN9D4lg=
X-Google-Smtp-Source: AGHT+IGKQ2aO/anLbdk1zzHbC+HkP1zLoMhudOJPn6G5ytpHFaFMnYb6AYav6eyFC5MZLB3zh5Wj7w==
X-Received: by 2002:a05:6a20:3d86:b0:1d9:ddf:b092 with SMTP id
adf61e73a8af0-1dc22b360f0mr14103156637.11.1731557278819;
Wed, 13 Nov 2024 20:07:58 -0800 (PST)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Content-Language: 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: <235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
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>
View all headers

On 11/12/24 12:10 PM, Left Right via Python-list wrote:
> 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.

On any Unix system this is untrue. Rotating a log file is quite simple:
simply rename the log file, then send a signal to the process to close
the log file handle and open a new one. After that perhaps compress the
rotated log file. Nothing is lost. This is standard practice in Unix.
It is reliable.

Perhaps the scenario you posit would happen on Windows.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Left Right
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 07:03 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivokon@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Thu, 14 Nov 2024 08:03:32 +0100
Lines: 17
Message-ID: <mailman.108.1731567826.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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de h3kKC+sibh4R+WANoMQG5QabUEzI84PHmZrcJz74jFZA==
Cancel-Lock: sha1:UJwpvXSEEP5hNq98hIlOABclSso= sha256:AfKCeaFa0VbbBrIMv6hR+wOb51yfaJU71dxlfPQIQLc=
Return-Path: <olegsivokon@gmail.com>
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=gmail.com header.i=@gmail.com header.b=cvD3rN9F;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.029
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'lecture': 0.07;
'subject:name': 0.07; '"as': 0.09; 'cc:addr:python-list': 0.09;
'fact,': 0.09; 'log': 0.12; 'cc:no real name:2**0': 0.14;
'"standard"': 0.16; '(instead': 0.16; 'experts.': 0.16; 'infra':
0.16; 'received:mail-oi1-x236.google.com': 0.16; 'simple:': 0.16;
"aren't": 0.19; 'cc:addr:python.org': 0.20; 'subject:file': 0.22;
'cc:2**0': 0.25; 'wrong': 0.28; 'message-id:@mail.gmail.com':
0.31; 'simple,': 0.32; 'words,': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34; 'mean': 0.34;
'from:addr:gmail.com': 0.34; 'also,': 0.36; 'really': 0.36;
'people': 0.36; 'file': 0.38; 'way': 0.38; 'quite': 0.39;
'developers': 0.39; 'wrote': 0.39; 'appears': 0.40; 'something':
0.40; 'popular': 0.60; 'above': 0.62; 'gives': 0.62; 'tool': 0.65;
'latter': 0.69; 'url:info': 0.71; 'experts': 0.76; 'rotating':
0.84; 'subject: \n ': 0.84; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731567823; x=1732172623; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=NfYM+wDf8qWaOtl8nVByjSMTJvAxLVvPv4IVc2x2CPk=;
b=cvD3rN9FnnDoDANwaZJJlM6rpVeJTwm2gygk3PODGbz2fbMe3oczulQfX7sbq1TL8X
8HvBF+DWndkRgUerTpxDb0rH8rWQ3oUO9VbwUGHtERs6dtaQVYRYs2Cdc/FFNKaf8xmj
viEtIytx7FxcV66Z6ZZb/OQh3jPKVUENUkZXVmyx/TUcX7VypzNEHppW/Py89cxDwBjr
5ZVcC8g8g+aufwEdXEIRbFFyZe7BZumLYUi0LFfV/wonzzrw/I6PHhZWYgQKzlBSkB0J
Bl4Vjl/NYJsuMFX9golsMyoA5W0Nvb1rSDtOmzCxEvR/aNtixs077AmXprkwzPNY7vXP
oROw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731567823; x=1732172623;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=NfYM+wDf8qWaOtl8nVByjSMTJvAxLVvPv4IVc2x2CPk=;
b=lHNTczDzsY3nh20YFq42nhPL1n/Chu2qSxPY+4F39Odmy/WUHrg/ObO4C9ho1PhIiN
d52JhnfXayLoRTCaAq8Uz3Vm9W8rOaJVDjdBJUQ7TZmZXeDVxiURyu/72eCg6CfVfRLt
hoQi/VRDeMBRmrkY5n7sOgtrLUxL1SmGC2ZZ8Y/NWy6IBZ+3IuwBz7wimTGoqIIkNn9J
gV+MC3Nl1onE4Nj73OotzH1Md+EOnj1zltBeN+HUPpkTzWldlft5g/zT/zzn1mQDODuS
f/O2/dFVL1n25XcLwE4Nyz29n7ld43s2lxQpGgE14litWPbrzXfKXl2ITp4+2XxT90Ti
VwFg==
X-Gm-Message-State: AOJu0YyYVk8dDxRmTdwsno/q/i7ITQqs6BSOtrEP59T2ts/tUJnr7KdZ
F9lgLwTDmnA4QNBmTjlbx8vYSqlI1VdAtfxXFMB6q5xZOpC566Mr2X5gzU3dqK5dZLIqcrX/LUh
hF8t5PSI+OpNz2dMvv5+Uw75u908=
X-Google-Smtp-Source: AGHT+IF/Ev3kXLDJrtN5inofui2kK3tp03A3bH0SinVRMHA6qRevm7Eipag5bUpsYCI1adTsCDNkI2o/CEa9LQ8UIOA=
X-Received: by 2002:a05:6808:2381:b0:3e6:6005:e36f with SMTP id
5614622812f47-3e794685478mr23812930b6e.5.1731567823548; Wed, 13 Nov 2024
23:03:43 -0800 (PST)
In-Reply-To: <235f9d53-f784-8998-f201-1c01dbbf14ba@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: <CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
View all headers

> On any Unix system this is untrue. Rotating a log file is quite simple:

I realized I posted this without cc'ing the list:
http://jdebp.info/FGA/do-not-use-logrotate.html .

The link above gives a more detailed description of why log rotation
on the Unix system is not only not simple, but is, in fact,
unreliable.

NB. Also, it really rubs me the wrong way when the word "standard" is
used to mean "common" (instead of "as described in a standard
document"). And when it comes to popular tools, oftentimes "common"
is wrong because commonly the tool is used by amateurs rather than
experts. In other words, you only reinforced what I wrote initially:
plenty of application developers don't know how to do logging well.
It also appears that they would lecture infra / ops people on how to
do something that they aren't experts on, while the latter are :)

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Chris Angelico
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 08:13 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Thu, 14 Nov 2024 19:13:54 +1100
Lines: 20
Message-ID: <mailman.109.1731572048.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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
<CAPTjJmpaAcHAhoRS=yW+faR4nFoaX_6syTQX1XSRL9vnUd2Sng@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de LCeEDkH/ySpFT8PPp9TcKgnelzHtmPtQfsoyY41SzgMA==
Cancel-Lock: sha1:pYTtkFXcfZpnmiWuugpL5PtFeEc= sha256:WtDsFUZGdiuvQuUIlme/j6rn1nMjCqmaMf6OMsFzIiM=
Return-Path: <rosuav@gmail.com>
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=gmail.com header.i=@gmail.com header.b=KfZS0fO2;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.065
X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'subject:name': 0.07;
'cc:addr:python-list': 0.09; 'fact,': 0.09; 'log': 0.12; 'cc:no
real name:2**0': 0.14; 'assuming': 0.16; 'chrisa': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'simple:': 0.16; 'wrote:': 0.16; 'thu,': 0.19;
'cc:addr:python.org': 0.20; 'subject:file': 0.22; 'cc:2**1': 0.23;
"isn't": 0.27; 'message-id:@mail.gmail.com': 0.31; 'performed':
0.32; 'python-list': 0.32; 'simple,': 0.32; 'tool.': 0.32; 'but':
0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.34;
'necessarily': 0.37; 'file': 0.38; 'quite': 0.39; 'setting': 0.39;
'here.': 0.61; 'above': 0.62; 'gives': 0.62; 'tool': 0.65;
'right': 0.68; 'forcing': 0.69; 'skip:/ 10': 0.69; 'url:info':
0.71; 'left': 0.83; 'rotating': 0.84; 'subject: \n ': 0.84;
'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731572046; x=1732176846; darn=python.org;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=ZApvZ2jyF1ZYzzrBVGfgTP2sAkz1P7zMBp954moIcXA=;
b=KfZS0fO2aU4jtK7mv8LBXIJ55buhhMjNhF1M/v4Q1VJgtplzrn42cPOEEE6pEb76bl
oqsqET111J6T2YQKBH5uLV6JKnW0UaTd2or35MVDAcWZ/EU50QrpBwhEtJb1PSIBYYUB
+AYJXWM/4MvMvOUuKZnA6xCCN8LOwUuMM4dj9LtuKrfOy+J3tHIsc69or9ecXITuQkgg
rEIuDWFJfNJfXwr/qE/+b7iHkmU6oBYswN3QU46qo6HJVUJD8h4l5Tk1MJRLnJbNmwW5
hbYFXGDrDJ1jJ9OWgQ5AFLlhydYyxQ4yplVircKxBRCH3GHfHSEPpKf7DmgIuJq8Je2G
bOCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731572046; x=1732176846;
h=cc:to:subject:message-id:date:from:in-reply-to:references
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=ZApvZ2jyF1ZYzzrBVGfgTP2sAkz1P7zMBp954moIcXA=;
b=rXbNXIfviTiK9xPj6iTatuhtZxdsykbDdyVb0hrUr7fW5NjmYBGxnExOB8YkwbQda0
ni8YwTL+3pOdXwlfjN3T+E1pXwe55PeurKHWw6ljnFkQdQUyj1kz6Tbrq+Eqe3N4KDGj
ET5uIxT/DOVOrtWEoYgGb5gWjlTqooVEJzZbjH/0K3k/hGv9VynwbiIHFmran4zOvDcU
cxRaTFI0VugheQ4Z904z8PjzeCq+fmupQQtPG461a71/F2E+I6wusrWDHSQT4Pg5IVfU
ByN6gG4b5Z1qEnkh8svjoA396p+n7PyFBseXOId0+zpBWYq/FHgEd9iDvU1fMKZDSGnB
tfnA==
X-Forwarded-Encrypted: i=1;
AJvYcCVsE9Dis5GQjXDoorQD7aemhwxsykCck0GNtCUTLiFppZpMRSSKm5FFaudPlZSCI137YaTGei64bGBIUg==@python.org
X-Gm-Message-State: AOJu0YyN5whBUlq2oEGdE/3LoXkm3qqMASY6sNaJuMeKLVKjLS0YxM5c
RiUuUFuGkJ97B7ioCLtkUHY0uiEty/IfQEWdGxGto3xtJWYko3bjTU7TulGa6DCgYyE+vlkJsOH
g0cEGjE2KjGzne+QbajfwlsnvKzk91A==
X-Google-Smtp-Source: AGHT+IFX6lHSM/MofgbRV9w+RCkk4nxShk0uZXHNtMiX/QC4RQ3FVQEf+G1xJZU/5rVrychEPN2WN4f0LpPWP6XQEM8=
X-Received: by 2002:a05:6512:398d:b0:536:55a8:6f78 with SMTP id
2adb3069b0e04-53da5c42103mr529525e87.17.1731572045278; Thu, 14 Nov 2024
00:14:05 -0800 (PST)
In-Reply-To: <CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@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: <CAPTjJmpaAcHAhoRS=yW+faR4nFoaX_6syTQX1XSRL9vnUd2Sng@mail.gmail.com>
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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
View all headers

On Thu, 14 Nov 2024 at 18:05, Left Right via Python-list
<python-list@python.org> wrote:
>
> > On any Unix system this is untrue. Rotating a log file is quite simple:
>
> I realized I posted this without cc'ing the list:
> http://jdebp.info/FGA/do-not-use-logrotate.html .
>
> The link above gives a more detailed description of why log rotation
> on the Unix system is not only not simple, but is, in fact,
> unreliable.

You're assuming a very specific tool here. Log rotation isn't
necessarily performed by that one tool. There are many ways to do it.

Log to stderr. That puts the power in the hands of the sysadmin,
rather than forcing trickery like setting the log file name to be
/proc/self/fd/2 to get around it.

ChrisA

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: D'Arcy Cain
Newsgroups: comp.lang.python
Organization: Vybe Networks Inc.
Date: Wed, 13 Nov 2024 13:37 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: darcy@VybeNetworks.com (D'Arcy Cain)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Wed, 13 Nov 2024 06:37:47 -0700
Organization: Vybe Networks Inc.
Lines: 16
Message-ID: <mailman.111.1731593052.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>
<79074400-022a-42d8-b1c7-2fe53c5c7007@VybeNetworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de O5pC7mgWo5wiD5WggFP6awIrjMVGh49e6MSQVmKwdhdA==
Cancel-Lock: sha1:RfN8qtVzlsYIRckQ9CLe0HSsQHI= sha256:r6TPB07f/ljxjGJZpdeL4s94gbD3S7rXhuTHi/4+Dm8=
Return-Path: <darcy@VybeNetworks.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=vybenetworks.com header.i=@vybenetworks.com
header.b=LVABflgd; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.320
X-Spam-Level: ***
X-Spam-Evidence: '*H*': 0.43; '*S*': 0.07; 'subject:name': 0.07;
'roel': 0.09; 'schroeven': 0.09; 'logs': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'subject:file': 0.22; 'task': 0.26;
'header:User-Agent:1': 0.30; 'python-list': 0.32;
'header:Organization:1': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'networks': 0.35; 'usual': 0.35; 'files': 0.36;
"it's": 0.37; 'received:192.168': 0.37; 'file': 0.38; 'use': 0.39;
'services.': 0.39; 'received:98': 0.40; 'something': 0.40; 'day,':
0.62; 'similar': 0.63; 'simply': 0.63; 'let': 0.65; 'per': 0.68;
'and,': 0.69; 'days,': 0.69; 'older': 0.70; 'inc.': 0.73;
'rotating': 0.84; 'subject: \n ': 0.84; 'url-ip:98/8': 0.84;
'hand.': 0.91; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=vybenetworks.com;
s=VEXNET; t=1731505071;
bh=a7xNM6J4Yo6cm4ixecW/6ahiW+etT8N0Ghozd8Dm3u4=;
h=Date:Subject:To:References:From:In-Reply-To;
b=LVABflgdjXnM1IWvjxA4O8G0TAEpZ2B+1I8E4wGiPzuJrqMpvVjc71TX7FUPW5W2A
+O/c2GpRTI9sB+A/LC0wj9RWxI+orBkMQhd7YBveR4ZMd7PoUDwvh2XTQbr7kkvLzJ
DcCF9hqo8ZRBWWsrS6wmbBG5y6CNENFG52w8zwxc=
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <5f972e7d-e72d-459b-9148-0af977a82ead@roelschroeven.net>
X-Mailman-Approved-At: Thu, 14 Nov 2024 09:04:11 -0500
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: <79074400-022a-42d8-b1c7-2fe53c5c7007@VybeNetworks.com>
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>
<5f972e7d-e72d-459b-9148-0af977a82ead@roelschroeven.net>
View all headers

On 11/13/24 02:12, Roel Schroeven via Python-list wrote:
> 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.

I do something similar for my system logs except that I let the system
use the usual names and, at midnight, I rename the file appending the
previous day's date to it and restarting services.

--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:darcy@VybeNetworks.com VoIP: sip:darcy@VybeNetworks.com

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Barry
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 16:01 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: barry@barrys-emacs.org (Barry)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file,
rather than file itself
Date: Thu, 14 Nov 2024 16:01:42 +0000
Lines: 17
Message-ID: <mailman.112.1731600995.4695.python-list@python.org>
References: <87iksrehh6.fsf@zedat.fu-berlin.de>
<C4D98083-D2F1-4490-B342-5AA94DB9E4B1@barrys-emacs.org>
Mime-Version: 1.0 (1.0)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de NxSb48Esbtwje8mH/y6cqwubyO2V9xODVyxDVSlycq4A==
Cancel-Lock: sha1:kDIvQilZ9Mzs1/VP4mkEDdvcaZY= sha256:mVYfvv/Q66klCsHaCo1O2EsTs8ekEKPGX1hpCEfWoIA=
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'is.': 0.05;
'subject:name': 0.07; 'suggestion': 0.07; 'cc:addr:python-list':
0.09; 'from:addr:barry': 0.09; 'linux': 0.09; 'received:217.70':
0.09; 'received:217.70.178': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; 'log': 0.12; 'cc:no real
name:2**0': 0.14; 'barry': 0.16; 'bennett': 0.16; 'from:addr
:barrys-emacs.org': 0.16; 'logs': 0.16; 'message-id:@barrys-
emacs.org': 0.16; 'wrote:': 0.16; 'cc:addr:python.org': 0.20;
'subject:file': 0.22; 'run': 0.23; 'cc:2**0': 0.25; 'program':
0.32; 'python-list': 0.32; 'header:In-Reply-To:1': 0.34; 'mean':
0.34; 'running': 0.35; '...': 0.37; 'put': 0.38; 'quite': 0.39;
'should': 0.40; 'service': 0.64; 'your': 0.64; 'let': 0.65;
'received:217': 0.67; 'subject:than': 0.91
In-Reply-To: <87iksrehh6.fsf@zedat.fu-berlin.de>
X-Mailer: iPad Mail (22B83)
X-GND-Sasl: barry@barrys-emacs.org
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: <C4D98083-D2F1-4490-B342-5AA94DB9E4B1@barrys-emacs.org>
X-Mailman-Original-References: <87iksrehh6.fsf@zedat.fu-berlin.de>
View all headers

> On 14 Nov 2024, at 14:07, Loris Bennett via Python-list <python-list@python.org> wrote:
>
> I don't quite understand what your suggestion is. Do you mean that I
> should log to stderr and then run my program as
>
> my_program ... 2>&1 | logger

On almost all Linux distros you would run a long running program as a systemd service and let it put logs into the journal. I wonder if that was what was being hinted at?

Barry

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Ethan Furman
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 17:32 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ethan@stoneleaf.us (Ethan Furman)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Thu, 14 Nov 2024 09:32:32 -0800
Lines: 33
Message-ID: <mailman.113.1731605919.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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
<606e45ca-7d2c-38f2-7850-e04b22b697f2@stoneleaf.us>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de lKvk2IEJSoUWqMEQNXEe8wZqHJMVf7S4fiSJXtH/IRPA==
Cancel-Lock: sha1:nNqGKMsbcwakzx81gp2qV+NuIJo= sha256:Y3VOIougKU8RWNFO+xXJsqLfRwcDKaOkBy6l/RpZTlY=
Return-Path: <ethan@stoneleaf.us>
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=stoneleaf.us header.i=@stoneleaf.us header.b=aKDlxcjN;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; "python's": 0.05;
'lecture': 0.07; 'subject:name': 0.07; '"as': 0.09; 'fact,': 0.09;
'post.': 0.09; 'received:217.70': 0.09; 'received:217.70.178':
0.09; 'received:gandi.net': 0.09; 'received:mail.gandi.net': 0.09;
'log': 0.12; '"standard"': 0.16; '(instead': 0.16; 'appropriate.':
0.16; 'experts.': 0.16; 'from:addr:ethan': 0.16;
'from:addr:stoneleaf.us': 0.16; 'from:name:ethan furman': 0.16;
'infra': 0.16; 'message-id:@stoneleaf.us': 0.16; 'simple:': 0.16;
'things,': 0.16; '~ethan~': 0.16; 'wrote:': 0.16; 'python': 0.16;
"aren't": 0.19; 'to:addr:python-list': 0.20; 'subject:file': 0.22;
'list,': 0.24; 'python,': 0.25; 'wrong': 0.28; 'header:User-
Agent:1': 0.30; 'program,': 0.31; 'python-list': 0.32; 'simple,':
0.32; 'window': 0.32; 'words,': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; 'mean': 0.34; 'yes,': 0.35; 'also,': 0.36;
'really': 0.36; 'people': 0.36; 'could': 0.37; 'file': 0.38;
'way': 0.38; 'read': 0.38; 'quite': 0.39; 'developers': 0.39;
'wrote': 0.39; 'appears': 0.40; 'something': 0.40; 'popular':
0.60; 'above': 0.62; 'gives': 0.62; 'your': 0.64; 'claims': 0.64;
'lost': 0.64; 'thus': 0.64; 'tool': 0.65; 'areas': 0.67;
'received:217': 0.67; 'right': 0.68; 'article,': 0.69; 'latter':
0.69; 'url:info': 0.71; 'relevant': 0.73; 'experts': 0.76; 'left':
0.83; 'rotating': 0.84; 'subject: \n ': 0.84; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stoneleaf.us;
s=gm1; t=1731605555;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references;
bh=VkUjmEE/Bq35cftfvFo3QZu2JwuZBHj6KLd85o2noZI=;
b=aKDlxcjNXCijpUqbZta0Mvxx0N9/vUQy+Pf7yWLUnKLnBrnVYEjKKHFPEzURb4edE+Pd9u
wOOFl0kv+OycHcbvoaiOo8dvZjllWGs3new0M2s0VUYCZeeWKORX/5kEk3SIbIALrDd5DF
CgMLZ60QdajNuEdZLC0c4meO5zssPYDkynE/VWd34ZJ/HU53sz3ZEX/zWsI0i2stOrYyq1
qIZ1EnDp5NOr26WWKae3d7zu0JsGHUjBt+LvBoE/1VloLo2T01Ff3atwXYkB+QtIqsA/s6
IJFPZECcnEVpRhNZmZ5S1+7SvTYArjvoY71z3oNElrZWk1m3dXxfIeEAXH6k6g==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
X-GND-Sasl: ethan@stoneleaf.us
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: <606e45ca-7d2c-38f2-7850-e04b22b697f2@stoneleaf.us>
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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
View all headers

On 11/13/24 23:03, Left Right via Python-list wrote:

>> On any Unix system this is untrue. Rotating a log file is quite simple:
>
> I realized I posted this without cc'ing the list:
> http://jdebp.info/FGA/do-not-use-logrotate.html .
>
> The link above gives a more detailed description of why log rotation
> on the Unix system is not only not simple, but is, in fact,
> unreliable.

Having read the linked article, I see it is not relevant to Python, as Python's logging tool is
the writer/rotator program, thus no window for lost entries exists.

> NB. Also, it really rubs me the wrong way when the word "standard" is
> used to mean "common" (instead of "as described in a standard
> document").

Yes, that is irritating.

> And when it comes to popular tools, oftentimes "common"
> is wrong because commonly the tool is used by amateurs rather than
> experts. In other words, you only reinforced what I wrote initially:
> plenty of application developers don't know how to do logging well.
> It also appears that they would lecture infra / ops people on how to
> do something that they aren't experts on, while the latter are :)

Well, since this is a Python list, perhaps you could make sure your advice is also Python appropriate. I appreciate
diversions into general areas and learning new things, but your general claims were untrue when it comes to Python
specifically, and that was unclear until I read your linked post.

--
~Ethan~

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Michael Torrie
Newsgroups: comp.lang.python
Date: Thu, 14 Nov 2024 15:44 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: torriem@gmail.com (Michael Torrie)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Thu, 14 Nov 2024 08:44:56 -0700
Lines: 30
Message-ID: <mailman.114.1731606301.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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
<541261c9-5d96-b52f-536a-a60bec679d63@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de p9oyBJD8TvLenbNsoypxiQhD3dFmJk7FOtW6O+FJpnYg==
Cancel-Lock: sha1:CSh3H9UIHsaXakvk72Mh29xJPUU= sha256:OBcel9TN0xbwDTmEGEfUUYlu4R9XtqbczcYd6NAqa/c=
Return-Path: <torriem@gmail.com>
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=gmail.com header.i=@gmail.com header.b=jewa5hd3;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.256
X-Spam-Level: **
X-Spam-Evidence: '*H*': 0.50; '*S*': 0.01; 'argument': 0.04;
'subject:name': 0.07; 'fact,': 0.09; 'mechanism': 0.09; 'log':
0.12; 'another.': 0.16; 'anything,': 0.16; 'denial': 0.16;
'informing': 0.16; 'renaming': 0.16; 'simple:': 0.16; 'wrote:':
0.16; 'message-id:@gmail.com': 0.18; 'gnu': 0.19; 'to:addr:python-
list': 0.20; 'subject:file': 0.22; 'actual': 0.25; 'header:User-
Agent:1': 0.30; 'am,': 0.31; 'simple,': 0.32; 'but': 0.32;
'there': 0.33; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'fill': 0.34; 'requires': 0.34;
'from:addr:gmail.com': 0.34; 'close': 0.35; 'files': 0.36;
'cases': 0.36; 'processes': 0.36; 'source': 0.36; 'using': 0.37;
'could': 0.37; 'author': 0.37; 'received:192.168': 0.37; 'file':
0.38; 'both': 0.38; 'quite': 0.39; 'files.': 0.40; 'above': 0.62;
'gives': 0.62; 'miss': 0.62; 'once': 0.63; 'service': 0.64;
'your': 0.64; 'his': 0.65; 'let': 0.65; 'years': 0.65;
'technical': 0.67; 'respond': 0.68; 'right': 0.68; 'during': 0.69;
'latter': 0.69; 'you.': 0.70; 'url:info': 0.71; 'little': 0.73;
'article': 0.73; 'causing': 0.75; 'unit': 0.81; 'left': 0.83;
'biggest': 0.84; 'legitimate': 0.84; 'rotating': 0.84; 'subject:
\n ': 0.84; 'journal': 0.91; 'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1731599098; x=1732203898; darn=python.org;
h=content-transfer-encoding:in-reply-to:from:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:from:to:cc:subject:date:message-id:reply-to;
bh=54S6Rla63UgP/qGWcNeYvtBu4TKJorAfIdgm+4n82iQ=;
b=jewa5hd37mEjxbGKIwa5An9T8HxRZcDSJye3ndhp0FPFVskDetwQPTMPSYcuWq5oeO
nEDAdtWfPbDTyMfbwpRh9+f2OiKjccpgM9fUEEW5zjZ111YGQS3X4VS5QfAvkLSXUsYK
MV5kRFm1MAH5rh9uOlGBioozt9gC8+8j6RYTVKVDwaHnAC8uYTdi745Ta+CiIciqhDrn
Kp2t4d6dW3vP6ilQ+LgIjQN1AWtE1uLwCB+qJQCZmOqkKNSiMcu8mN5zgPSxxErG5OPc
uC3+xSn7kV1G6V0FukC+ZPw56loFZsz5saWvE7Xn2eFEtTjKRSXgaOPZAiZUiciRltCm
jeQQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1731599098; x=1732203898;
h=content-transfer-encoding:in-reply-to:from:references:to
:content-language:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=54S6Rla63UgP/qGWcNeYvtBu4TKJorAfIdgm+4n82iQ=;
b=bK1jsw4Nvq02j6t6HJuWra7zMJITBMj66UejGJLSrcVlLAYzyjozrQycnt1uiM0OUo
LF258cjNXMIIM3klPS3jcFzte+l2y0NSVHqOyvSMOtqyDeOzjzXSzSKHKnVJMNgVjCau
ZIih8PyR5lcamjSZAKTEEPi8QDIN5sOvpZ37QhutZaxSsOifssNV54oZnTpPHKq3kaK1
5tzb0iHomqvG4+il3kIP1HDYE3g1teI2od2kCyzc4WCc8QBX88LPa2MIg4FfsouUUcCo
Mhk2TFSLKg0Wr9Fu6wvZW0jBXyKaBMlNslDWtRllQTAwzpRgnAA6YvNYwCuOJjA4MYub
1WdA==
X-Gm-Message-State: AOJu0YxmNzP6xoUwg3F2xpIJA8n7ewx9Phoxh0FFYxoRWOg1lYwnPHNF
c3Tl5DSdhbdbV5PKM0/PlIVzkRpuxRSk4XuQvo/JPq0zYtGYUj7XbesR3D2S
X-Google-Smtp-Source: AGHT+IG+vw6R43S2Vy1NHLUtBYeSWDl6l87Df4Witg38huXevzNbwEtLj1nF7zDaFtzSvTRjCzqlGg==
X-Received: by 2002:a17:902:ecd0:b0:20f:c292:665d with SMTP id
d9443c01a7336-21183328e19mr143845745ad.0.1731599098474;
Thu, 14 Nov 2024 07:44:58 -0800 (PST)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Content-Language: en-US
In-Reply-To: <CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
X-Mailman-Approved-At: Thu, 14 Nov 2024 12:45:00 -0500
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: <541261c9-5d96-b52f-536a-a60bec679d63@gmail.com>
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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
View all headers

On 11/14/24 12:03 AM, Left Right wrote:
>> On any Unix system this is untrue. Rotating a log file is quite simple:
>
> I realized I posted this without cc'ing the list:
> http://jdebp.info/FGA/do-not-use-logrotate.html .
>
> The link above gives a more detailed description of why log rotation
> on the Unix system is not only not simple, but is, in fact,
> unreliable.

Nothing in that article contradicts what I said about renaming log
files. His argument is that renaming log files messes with tail -F, and
therefore broken and unreliable. Which a pretty strange argument. tail
-F might not see some data during the rotation, but the log files
themselves don't miss anything, which was my contention. In all my
years of sysadmin-ing I have never once worried about problems GNU tail
might have with a file that gets rotated out from under you. Not sure
why the author is so fixated on it.

There are actual legitimate issues at play, such as a mechanism for
informing the process to close the file (rotate usually requires
processes to respond to SIGHUP). And of course the disk can fill up
causing a denial of service of one kind or another. The latter is the
biggest source of problems.

Of course you could just log using the standard libc syslog facility.
Or better yet, start your process from a systemd unit file and let the
journal automatically log stderr. In both cases that would satisfy the
technical objections of the author of that little treatise.

Subject: Re: FileNotFoundError thrown due to file name in file, rather than file itself
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Thu, 14 Nov 2024 18:12 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Thu, 14 Nov 2024 18:12:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <slrnvjcfcc.5qt.jon+usenet@raven.unequivocal.eu>
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>
<235f9d53-f784-8998-f201-1c01dbbf14ba@gmail.com>
<CAJQBtgmQ0MLh2xYpUTwsSWhO1ra=QVuJRddn=17Pd7gKA=aM+g@mail.gmail.com>
<541261c9-5d96-b52f-536a-a60bec679d63@gmail.com>
<mailman.114.1731606301.4695.python-list@python.org>
Injection-Date: Thu, 14 Nov 2024 19:12:29 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2f4671eca7e24707234e53ceb583ab2b";
logging-data="3073120"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Tv2m2t3/Ai8LwoOF5Ni+Bx1N4FjwKtQw="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:VSmw50HuoH8S81TVM0OS8Luk0mY=
View all headers

On 2024-11-14, Michael Torrie <torriem@gmail.com> wrote:
> On 11/14/24 12:03 AM, Left Right wrote:
>>> On any Unix system this is untrue. Rotating a log file is quite simple:
>>
>> I realized I posted this without cc'ing the list:
>> http://jdebp.info/FGA/do-not-use-logrotate.html .
>>
>> The link above gives a more detailed description of why log rotation
>> on the Unix system is not only not simple, but is, in fact,
>> unreliable.
>
> Nothing in that article contradicts what I said about renaming log
> files. His argument is that renaming log files messes with tail -F, and
> therefore broken and unreliable. Which a pretty strange argument. tail
> -F might not see some data during the rotation, but the log files
> themselves don't miss anything, which was my contention. In all my
> years of sysadmin-ing I have never once worried about problems GNU tail
> might have with a file that gets rotated out from under you. Not sure
> why the author is so fixated on it.

I really wouldn't worry about anything Jonathan de Boyne Pollard says.

1

rocksolid light 0.9.8
clearnet tor