936 questions
2
votes
1
answer
67
views
Angle Embedder in Python Messing Up Logging Config
I wrote another question on this earlier, but could not pinpoint the issue on my side, here, I am giving a minimal reproducible code.
System
Angle version 0.5.6
UV 0.8.22
Python 3.12
Ubuntu 24.04
I ...
0
votes
1
answer
87
views
Logging without year:month:day but with hours:minutes:seconds,milliseconds
I try to get logging setup
hours:minutes:seconds,milliseconds
Example: 11:28:51,284
Actually I get
2025-10-08 11:44:07,658
This is the source with which I try to do it:
# --- Logging Setup ---
# --- ...
2
votes
1
answer
75
views
Why are ERROR logging messages reflected in the INFO logging file?
I wanted to print INFO and ERROR file separately in Python logging. When I use ERROR level, it's writing into both LEVEL defined files.
log_config.json:
{
"version": 1,
"...
0
votes
0
answers
44
views
Why is my Python logger placing log files in a completely different place from where I ask? [duplicate]
(Edit: skip to the end, this is all just context. I found the core of the issue later)
I'm writing a Python UI program that I aim to compile to a .exe with pyinstaller, and for that reason I wish to ...
1
vote
2
answers
109
views
logger from Jupyter notebook: does not work unless calling the root logger at least once
I would like to see the logging produced by some Python code from within a Jupyter notebook (logging version '0.5.1.2', python 3.12).
If I run the following code:
import logging
logger = logging....
0
votes
1
answer
81
views
How can I convert python dictionary to a json object with loggers in snowflake event table
I have a snowflake event table created. The below code inserts log records into event table.
import snowflake.snowpark as snowpark
import logging
def main(session: snowpark.Session):
LOGGER = ...
1
vote
0
answers
60
views
Is there a reason not to replace the default logging.Handler lock with a multiprocessing.RLock to synchronize multiprocess logging
I've got some code that, for reasons not germane to the problem at hand:
Must write very large log messages
Must write them from multiple multiprocessing worker processes
Must not interleave the logs ...
0
votes
0
answers
78
views
Assert a logger writes to stdout
I'm trying to assert the fact that my loggers writes to stdout, but I can't get it to work. I ran the logger in a python file to make sure it outputs something in the standard output.
So far, I can ...
3
votes
1
answer
95
views
How to prevent error on shutdown with Logging Handler / QObject?
In order to show logging messages in a PyQt GUI, I'm using a custom logging handler that sends the logRecord as a pyqtSignal.
This handler inherits from both QObject and logging.Handler.
This works as ...
0
votes
1
answer
99
views
fluentd config for a simple Python logging format
My python flask/Quart app has the following log format:
## 2025-04-04 05:16:07 INFO Running app...
How can I configure the <source> of fluentd config? I have tried:
<source>
...
1
vote
1
answer
320
views
PySide6 signal not emitting properly when passed to decorator
I have this decorator in python 3.11 that sends a signal encoding the arguments to a function call that it decorates, here:
def register_action(signal=None):
def decorator(func):
def ...
0
votes
0
answers
30
views
Controlling from the top the verbosity/logging level in unittest.TextTestRunner?
I would like to change via command-line the logging level of my unit tests - I am talking of the logging level, which means the amount of info that can help me debugging a module that I am testing (...
0
votes
0
answers
35
views
How to write logs with the current date and time to a Python file and use Yaml configuration file
import logging
import os
from pathlib import Path
from pydantic import BaseModel, Field, field_validator
# Configure logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
...
1
vote
2
answers
67
views
Is there a way to remove stack traces in python log handlers using filters or some other mechanism when calling Logger.exception()?
I know the subject sounds counter-intuitive but bear with me.
My goal is to have two rotating file log handlers, mostly for logger.exception() calls, one that includes stack traces and one that doesn'...
0
votes
0
answers
37
views
How to omit exc_info from logs when using coloredlogs in Python?
See this question about sending exc_info to a log file but not to the console using Python's logging module.
I want the exact same behavior, except that I'm using coloredlogs. How can I do this?
...
0
votes
1
answer
103
views
Why are logs not appearing in a file/console when using logging in Python with multiprocessing.Pool?
I'm trying to implement logging in a Python application where I use both threads and processes. I have a custom LoggingManager that uses a QueueHandler to push log records from multiple processes to a ...
0
votes
1
answer
290
views
How to prevent FastAPI from sending the exceptions to stdout
I have this application and app.exception_handler correctly handles the exceptions that arise. There is one problem though, i.e., it does not stop the exception to be displayed in the stdout. Is there ...
1
vote
0
answers
44
views
Multiprocessing logs with S3 log Handler in Python
I am trying to push logs for a multiprocessing job into ECS S3. Following is my code snippet:
logger.py
import logging
from S3_log_handler import S3LogHandler
def setup_logger():
# Set up the ...
0
votes
1
answer
63
views
Get package level logs into webservice between logging and structlog
So the situation is the following:
multiple internal packages written in python which do rarely log and if only use, these use the basic python logging module, since this is as far as I have read ...
1
vote
1
answer
70
views
How do I make a function restart? Specifically I'd like the "call_count" log to return to the start of the count
I'd like to make a function that restarts once it hits a certain number, as an example: if call_count > 7:
Return to 1 or 0, is this possible? and if it is can anyone help? Thanks
if call_count &...
0
votes
2
answers
89
views
Logger does not inherit config from parent process
Consider the following minimal setup:
/mymodule
├── __init__.py
├── main.py
└── worker.py
__init__.py is empty
main.py:
import sys
import logging
import multiprocessing
from test.worker import ...
1
vote
1
answer
83
views
I'm having issues with logging, is there anyway to fix this?
is there away to make this code not spam in the second file without interfering with any other functions? "Anomaly.log" is being spammed although "Bandit.log" is not being spammed, ...
0
votes
3
answers
61
views
How do I log when a function is called using counter and python logging?
I'm trying to log every time the function "Hello" finds 1.png. Is there a way to do this using counter or some other method, it would then log it into "anomaly.log" using logging, ...
1
vote
0
answers
107
views
'FileHandler' object has no attribute 'level'
I am working on using the Python logging package. I am using Python 3.12.8 from uv.
The documentation gives the following code snippet as an example:
import logging
logger = logging.getLogger(__name__)...
1
vote
1
answer
51
views
Why does using `logging.Formatter` prevent widget from being deleted?
Here is a MCVE, very simple piece of code creating a QMainWindow, with a central empty QWidget:
import sys
from PyQt5.QtWidgets import QWidget
class MyWidget(QWidget):
"""QWidget ...
0
votes
1
answer
76
views
Why doesn't the Python TimedRotatingFileHandler rollover, if there are Celery jobs running?
Python 3.12.3, Celery 5.3.6, Django 4.2.11, Ubuntu 22.04.4
I have an infrastructure of Django and Celery servers running simultaneously on an Ubuntu server.
For logging I use DiscordHandler and ...
1
vote
1
answer
69
views
Logging Inheritance in Python
I am currently developing a core utils package where I want to set some logging properties (I know that this is not best practice, but it´s for interal purposes and intended to generate logs). When I ...
2
votes
1
answer
261
views
How to suppress or summarize non-consecutive *duplicate* log messages from a Python library function called in a loop?
I'm using a Python library that logs messages using the standard logging module. The library code includes the following at the top of its modules:
import logging
logger = logging.getLogger(__name__)
...
-3
votes
2
answers
271
views
Python Logging : name 'log' is not defined [closed]
I am using python logging to write debug information to a file and print it to my screen :
logger=logging.getLogger()
logger.setLevel(logging.INFO)
file_handler = logging.FileHandler("std.log&...
0
votes
1
answer
64
views
Flask DEBUG logging not working with dictConfig root confirguration
I do not seem to be able to make logging work. The following does not print anything to console.
I have been digging into the official documentation, SO, and even Reddit... and nothing seems to work ...
0
votes
1
answer
79
views
Python Logging not getting the desired caller class and line number
I have a python class wrapper to the logging functionality.
My problem with these solutions is the logging options "%(asctime)s:[%(filename)s->%(funcName)s():%(lineno)s] %(levelname)s>> %...
0
votes
0
answers
130
views
Gracefully terminate tkinter app (including multithreading, multiprocessing, QueueHandler, QueueListener)
Question
How to make a python tkinter app close gracefully at the end of normal operation and if user terminates the window interrupting the processing being performed?
Details
The tkinter app ...
0
votes
1
answer
65
views
How to print errors like python does by default?
Considering the following errornous function:
def inner():
raise Exception("message")
If I run the function I get an error like:
Traceback (most recent call last):
File "/...
1
vote
1
answer
161
views
Python logging: where are messages coming from
I have an application using lots of different packages and many of them are logging output. I would like to clean up my application's logs and perhaps disable some of the other packages' output. My ...
-1
votes
2
answers
62
views
emit different logs in different format based on condition like security events, normal software operation events etc to the std out
I am stuck at situation where i have to
emit logs in different format based on condition like security events, normal software operation events etc to the std out.
example
lets say
security events ...
0
votes
0
answers
58
views
Null values in log file from Python logging module when used with Dask
I have been trying to setup logging using the logging module in a Python script, and I have got it working properly. It can now log to both the console and a log file. But if fails when I setup a Dask ...
4
votes
1
answer
64
views
How can I subclass logging.Logger without breaking %(filename) in logging.Formatter's interpolation syntax
I am trying to write a custom logging.Logger subclass which is mostly working, but I run into issues when trying to use a logging.Formatter that includes the interpolated value %(filename) in the ...
1
vote
1
answer
72
views
Is this a valid approach to use POSIX signals to set logging levels dynamically in python? [closed]
I want to be able to set python logging level to DEBUG when I am debugging the application, without stopping it.
I wrote a signal handler which toggles the level. Is this a valid approach?
...
3
votes
2
answers
126
views
Is there a way to print incremental time instead of absolute time with Python logging
When using Python logging, asctime is very handy in looking at the hotspots in code. However, I have to decode or post-process the log to show incremental time taken between each log message.
logging....
0
votes
0
answers
155
views
Why is my log file empty in my python script?
I am trying to output the errors, if there are any in the code, and also the results of the stored procedure in my log file. The log file is created but it is empty. I have other logging in my code ...
0
votes
1
answer
162
views
How can I make a threadsafe logging handler subclass that triggers events in the main Qt loop?
I have a PySide6 application that uses threading and logging. My logger has a custom handler defined below, which pops up a messagebox that requires user attention for higher level logging events:
...
0
votes
1
answer
70
views
logging/print statements not being captured when running script with Runas command
I am running a python script as a different user with the runas command but I cannot see my output/errors anywhere. I am trying to debug my script, but I cannot see any logging info so it is near ...
1
vote
1
answer
57
views
Logging configuration does not take effect [duplicate]
logging.basicConfig(
filename=f"{output_location}/log.txt",
format="{asctime} - {levelname} - {filename}: {message}",
datefmt = "%d %b %H:%M",
...
0
votes
2
answers
140
views
Python 3.11 os can't read log files
I have a working logger module built on DBR 10.4/python 3.8 platform that creates the log and periodically export to a blob storage. Recently we've moved to DBR 15.2/python 3.11, and now the logger ...
-1
votes
1
answer
36
views
Not working with different levels of programming in Python for logging and for the browser?
Don't the different logging levels in Python (v3.11.4) logging work for a file and for telegrams?
So the logs of the WARNING level and above go both to the Telegram and to the file, and the logs of ...
0
votes
2
answers
299
views
Selenium wire hide redundant logging
I am using SeleniumWire, Django, Celery for parsing
I have a lot of redundant logs from selenium-wire. I mean logs:
Capturing request: sitename
Capturing response: sitename 200 OK
I want to hide ...
0
votes
0
answers
398
views
How can I fix a 'socket.gaierror: [Errno 11001] getaddrinfo failed' when trying to use an SMTPHandler in Python 'logging'?
I am currently trying to log using the SMTPHandler class from Python's logging module. The logger is instantiated just fine, but fails when calling _socket.getaddrinfo even though it is being passed ...
1
vote
1
answer
78
views
Is it possible to conditionally override levelname in formatting of Python logger?
I am currently working on some Python code that will be executed by a larger C# web project. The C# code uses NLog to create log files. I have got my Python logger logging to the same file. Also, I ...
3
votes
1
answer
90
views
Is this a good method to access a logging object across modules?
When using Python's built-in logging module, I see most examples access the log using something like log = logging.getLogger('SomeName'), across different modules/files in a program. You can do this ...
-1
votes
1
answer
43
views
Django application logs are not rotated
In a Django application, version 3.2.14, running on an ec2 instance that also has a gunicorn web server with 9 workers, plus ngnix and with the log configuration shown below, the files are not rotated....