Skip to main content

All Questions

0 votes
1 answer
81 views

Custom log level accurate filename

TLDR How can I get a custom logging level to accurately find out the pathname? Problem description When I try and add my own custom logging levels (e.g. for very verbose program tracing) I want to ...
oliversm's user avatar
  • 1,987
1 vote
0 answers
172 views

How to format logging for the python http.server

Using the python http.server (see https://docs.python.org/3/library/http.server.html), I am running this as a systemd service. In order to get the output of the server, I define StandardOutputand ...
Lonerider's user avatar
0 votes
0 answers
213 views

How to format python logs in log file using logging.FileHandler as one of handlers in config dictionary?

I have two files: log.config.py This file contains all default configurations for logging and a method for 3 customization: whether to print logs in log file or not. whether to print logs in console ...
V-R's user avatar
  • 1
0 votes
1 answer
1k views

python logging config format

I am using the python logging module with a configuration file. It is working but I would like to change the format of the output string. Currently in the config file I have a line [...
Mick Sulley's user avatar
0 votes
0 answers
116 views

multiple arguments in logger and use them in formater - django

I want to send multiple arguments in logger messages and use them directly in formater. For example, logger.exception('Exception message, 'arg1', 'arg2') logger.warning('warning message, 'arg1', 'arg2'...
Harsh Shah's user avatar
2 votes
1 answer
2k views

How to test specific logging formatting in Python (using `pytest` and `unittest`)

I am implementing a specific logging format, which is going to be parsed by another service for logging/monitoring/alerting purposes. Due to this, the logging format needs to be very specific. I need ...
cyau's user avatar
  • 449
1 vote
1 answer
2k views

Python logging.Formatter uses "%"-formatting instead of "{" even when "{" specified

I tried to create a custom logger with a custom formatter, inheriting them from logging.Logger and logging.Formatter accordingly. However, even though I specified style to be "{", I get an ...
Евгений Крамаров's user avatar
1 vote
1 answer
854 views

LogRecord attributes in a derived logger

I want to use a logger which also knows to handle my additional log levels verbose and trace. Therefore I created a custom logger deriving from a base logger import logging class DefaultLogger(...
Max's user avatar
  • 108
0 votes
1 answer
305 views

Cannot change oslo_log log format

I was trying to configure the log format for oslo_log.log to let the log context contains the file name and line number. It seems that the log configuration has been changed but the output on the ...
Sean's user avatar
  • 25
1 vote
0 answers
33 views

how to form multiple log formats based on severity level for a specific destination - python logging

I'm a beginner in python and logging using logging package. I want to send info logs with a specific format differ from other levels (for example: debug, warning, ...) to a specific destination (for ...
freeman's user avatar
  • 11
19 votes
1 answer
24k views

Use lazy % formatting in logging functions pylint error message

I have a python function as follows, when enabled pylint to code scan, it throws me an lazy formatting error. def modify_response(data): try: response = {} response["User_ID&...
ashakshan's user avatar
  • 479
0 votes
1 answer
851 views

Python log formatter and string formatting don't mix

I have a logger that uses a Formatter and needs to log a message that includes a variable. Normal enough. If my logger doesn't user a formatter, all is fine. If it does, suddenly it doesn't know how ...
Ben Taylor's user avatar
2 votes
2 answers
2k views

Following Python Lazy Logging Formatting, but pylint is still showing (logging-not-lazy) messages

I'm logging some info messages and wanted to make sure I was following the PEP standards. Pylint says that this line: LOG.info('Directories have been made in /home/bushbak2/projects/'+ ...
Bushbaker27's user avatar
0 votes
1 answer
33 views

Python logging import inconsistent to print

When using logger this Import logging logging.info( f"This is a \nid: {id}", \ f"\nclaim number: {claim_number}") causes the error TypeError: not all arguments converted ...
AnonymousAlias's user avatar
0 votes
1 answer
328 views

Check if value was provided from within format string

I have a format string fmt on which the format method will be called in another module which I have no control over. In this format string I want to optionally include a field if it was provided as an ...
Chris's user avatar
  • 545

15 30 50 per page