How do you log in your projects?

Barry barry at barrys-emacs.org
Tue Feb 8 17:09:12 EST 2022



> On 8 Feb 2022, at 14:15, Lars Liedtke <liedtke at punkt.de> wrote:
> 
> Hello,
> 
> inspired by this thread https://mail.python.org/pipermail/python-list/2022-February/905167.html I finally came around to send in this question.
> 
> I know how to use python logging generally. Being on the DevOps-Side of things at the moment, I naturally began liking to run tools, which not only have logging, but also have different levels of logging configurable, because often when you run a couple of different services and software projects, logging is often the first help you turn to, and sometimes it is the only way to know what is going on. Not that the code of most (FLOSS) software is not available, but you simply do not have the time to read into the code of every piece of software you run.
> 
> So of course I want to write software on my own, if I have to or wpuld like to, that has got a decent amount of logging. But how often to actually log things? Of course the obvious answer is "it depends".
> 
> So how do you do your logging?
> - On a line per line basis? on a function/method basis?
> - Do you use decorators to mark beginnings and ends of methods/functions in log files?
> - Which kind of variable contents do you write into your logfiles? Of course you shouldn't leak secrets...
> - How do you decide, which kind of log message goes into which level?
> - How do you prevent logging cluttering your actual code?

You seem to be thinking about how to log the flow of the code.
That is useful to log when debugging your code. But depending
on your performance goals you may have to remove from the
production version.

But it is not what you do to be able to maintain a production service.
In this case you log events that the service is processing.

Barry

> 
> Maybe there are some questions I forgot, so please feel free to add whatever you think might help finding the best way of logging (tm)
> 
> Cheers
> 
> Lars
> 
> -- 
> punkt.de GmbH
> Lars Liedtke
> .infrastructure
> 
> Kaiserallee 13a    
> 76133 Karlsruhe
> 
> Tel. +49 721 9109 500
> https://infrastructure.punkt.de
> info at punkt.de
> 
> AG Mannheim 108285
> Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list