Questions tagged [python-logging]

"logging" is a python module used for logging output to the console. Mainly used for debugging.

The logging module is a python module for logging output to the console. Most often it is used for debugging a program by printing output when specific conditions are met.

880 questions
0
votes
1 answer

Extract logging from multiple objects

I'm having an issue configuring logging for multiple objects. Presently, I have two classes representing a server and a coordinator. These are composed such that a coordinator has a server as in instance variable. See below: class…
0
votes
1 answer

Duplicate log output, but no duplicate handlers

I am getting duplicate log output from a logger that only has 1 handler attached. How can I debug this? Code (should be copy-and-paste-able): import io import logging import os import sys from typing import Optional DEFAULT_LOG_LEVEL =…
shadowtalker
  • 12,529
  • 3
  • 53
  • 96
0
votes
2 answers

Log to sys.stdout from a module logger

I have the following simple test script: import logging import sys logger = logging.getLogger(__name__) handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.INFO) handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s -…
Aleksey Bilogur
  • 3,686
  • 3
  • 30
  • 57
0
votes
1 answer

How to send one log record to file and another to email using Python logging module with multiple handlers

I am using the handlers TimeRotatingFileHandler and the SMTPHandler. I want to send the INFO messages to the file log and the exceptions the email. My setup is below: import logging from logging.handlers import TimeRotatingFileHandler from…
JBoogie
  • 1
  • 1
0
votes
1 answer

Call a parent class's method from child class but don't see in the log file

I would like to call a parent class's method from child class but I don't see the logging entry in the log file when I run the following command: python.exe B.py If I call the printA() method in the A.py code then I see the logging entry. The…
Milky
  • 143
  • 4
  • 15
0
votes
1 answer

Exception stack trace logging along with method arguments' actual values calls in Python

I need to know how I can log an exception stack trace along with the method arguments' actual values. To clarify my requirement, please refer to following example: Code Sample import logging def a(str, str2): print str + str2 raise…
0
votes
1 answer

Info logger is not printing

Here is my code import logging logger = logging.getLogger('test') logger.setLevel(level=logging.INFO) logger.info('Hello World') I expect it to print out 'Hello World'. It does not do so. Could someone help me understanding why it does not print…
Denys
  • 4,287
  • 8
  • 50
  • 80
-1
votes
1 answer

How to prevent a Python AWS Lambda from logging an unhandled exception

EDIT: Added test method. EDIT: Added sample code and more detailed explination of the problem. How do I prevent a Python 3.8 AWS Lambda from logging an unhandled exception? We have a Python 3.8 AWS Lambda function that is only invoked directly, not…
-1
votes
1 answer

Formatting String in logging - module

i have one question concerning the logging module. I actually try to create my own handler and when i'm formatting the strings using "Logging.Formatter()", i have the following problem : The output should look like this : [ WARNING ] Someething Not…
NumeroUnoDE
  • 37
  • 1
  • 8
-1
votes
2 answers

Python execution log

I'd like to create a log for a Python script execution. For example: import pandas as pd data = pd.read_excel('example.xlsx') data.head() How can I create a log for this script un order to know who run the script, when was executed, when did it…
Rfl
  • 23
  • 5
-1
votes
2 answers

Log files are not getting created in python

Created Logger file and accessing the same in another file. But not getting any logging detailes. import logging class LogGen: @staticmethod def logGen(): logging.basicConfig(filename=".\\Logs\\automation.log", …
-1
votes
2 answers

How to use a custom console logger for the entire application in Python?

After reading the logging documentation of Python and several examples of how to customise the log format and output, I came to the conclusion that formatting can only be set for a single logger instance. But since all libraries in other modules use…
ygoe
  • 18,655
  • 23
  • 113
  • 210
-1
votes
1 answer

Update function name in logging

I am currently using the following code to log messages based on their log_level in customized fashion. What i am struggling is how to update or change the function name in the common LOG_MSG function. Currently it logs all messages with function…
Cheppy
  • 25
  • 5
-1
votes
2 answers

Unable to control structlog using logging

I'm unable to disable logging which is by default turned on via structlog Here's my code below: Input file contain: 5418531366 5418531367 import asyncio import pathlib import sys from arsenic import get_session, errors from arsenic.browsers import…
-1
votes
1 answer

Initialise logging config from conf file in Python

I want to initialise the logging config using a config file(json or yaml) only once when I call my main module. Is there a concept of context in python like we have in Java where I can take the logger from config whenever I need. Something like…
Gagan
  • 1
  • 3
1 2 3
58
59