"Value Error: Unable to configure handler'file_output_handler'" when starting a python program

Event

The code itself doesn't seem to be a problem, but for some reason I get an error.

.
..
...
LOG_CONFIG = {
    'version': 1,
    ...
    ..
    .
    'handlers': {
        'console': {
            'formatter': 'default',
            'class': 'logging.StreamHandler',
            'stream': 'ext://sys.stderr',
        },
        'output': {
            'level': 'DEBUG',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'formatter': 'default',
            'filename': '/path/to/application.log',
            'when': 'MIDNIGHT',
            'interval': 1,
            'backupCount': 5,
        },
    },
    ...
    ..
    .
}
...
..
.
.
..
...
  File "./main.py", line 7, in <module>
    load_log_config()
  File "./configs/log_config.py", line 41, in load_log_config
    dictConfig(LOG_CONFIG)
  File "/root/local/python-3.8.5/lib/python3.8/logging/config.py", line 808, in dictConfig
    dictConfigClass(config).configure()
  File "/root/local/python-3.8.5/lib/python3.8/logging/config.py", line 570, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'file_output_handler'

Cause

The cause is that the directory specified in filename does not exist (or is incorrect). The error message was hard to understand and I was a little addicted to it ...

.
..
...
LOG_CONFIG = {
    'version': 1,
    ...
    ..
    .
    'handlers': {
        'console': {
            'formatter': 'default',
            'class': 'logging.StreamHandler',
            'stream': 'ext://sys.stderr',
        },
        'output': {
            'level': 'DEBUG',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'formatter': 'default',
            'filename': '/path/to/application.log',← This
            'when': 'MIDNIGHT',
            'interval': 1,
            'backupCount': 5,
        },
    },
    ...
    ..
    .
}
...
..
.

Recommended Posts

"Value Error: Unable to configure handler'file_output_handler'" when starting a python program
Python Note: When assigning a value to a string
When writing a program in Python
Error when installing a module with Python pip
Error when trying to install psycopg2 in Python
Output timing is incorrect when standard (error) output is converted to a file in Python
[Python] What to check when you get a Unicode Decode Error in Django
Error due to conflict between python when using gurobi
Things to note when initializing a list in Python
From buying a computer to running a program with python
Specifies the function to execute when the python program ends
A program to write Lattice Hinge with Rhinoceros with Python
Summary of points to keep in mind when writing a program that runs on Python 2.5
A program that failed when trying to create a linebot with reference to "Dialogue system made with python"
[Django] A memorandum when you want to communicate asynchronously [Python3]
I got a Value Error when using JUMAN ++ with PyKNP
How to run a Python program from within a shell script
I wrote a program quickly to study DI with Python ①
Write a python program to find the editing distance [python] [Levenshtein distance]
What to do when a Remove Error occurs when updating conda
[python] A note when trying to use numpy with Cython
[GCP] A memorandum when running a Python program on Cloud Functions
How to get the last (last) value in a list in Python
When you want to hit a UNIX command on Python
Extract the value closest to a value from a Python list element
A road to intermediate Python
Error when playing with python
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
[Subprocess] When you want to execute another Python program in Python code
How to batch start a python program created with Jupyter notebook
I tried to convert a Python file to EXE (Recursion error supported)
[Python] Execution time when a function is entered in a dictionary value
I want to run the Python GUI when starting Raspberry Pi
Simple code to call a python program from Javascript on EC2
Atom: Note for Indentation Error when copying Python script to shell
[Python] How to get a value with a key other than value with Enum
Unable to bind to interface error when using apollo federation with gqlgen
What to do when the value type is ambiguous in Python?
[Python] A program that rotates the contents of the list to the left
[python] Error when installing library ramkan
How to write a Python class
Error when building mac python environment
A pretty sloppy Python error solution
Unable to install Python with pyenv
5 Ways to Create a Python Chatbot
Eliminate WARNING when starting Python IDLE
Things to watch out for when creating a Python environment on a Mac
[Python] What is a formal argument? How to set the initial value
[Python] A program that finds a pair that can be divided by a specified value
I tried to create a program to convert hexadecimal numbers to decimal numbers with python
A story I was addicted to when inserting from Python to a PostgreSQL table
How to deal with OAuth2 error when using Google APIs from Python
What to do when pyinstaller: error: argument --add-binary: invalid add_data_or_binary value: appears
When you want to replace a column with a missing value (NaN) column by column
When running a Python shell from Electron, pass multiple arguments to run Python.
How to get a value from a parameter store in lambda (using python)
How to deal with SSL error when connecting to S3 with boto of Python
[Python / Pandas] A bug occurs when trying to replace a DataFrame with `None` with` replace`
I get a UnicodeDecodeError when trying to connect to oracle with python sqlalchemy
[Python] What to do when an error related to SSL authentication is returned
I made a program to notify you by LINE when switches arrive