The otb log level can't be changed after importing otbApplication in Python code

Context

I am trying to change the otb log level (not the pyotb log level) after importing otbApplication.

Configuration setup

My system: Redhat 8
Version of the OTB: 9.1.0
I installed the OTB with: I am using the otb on the CNES cluster, with a module load.
Python version: 3.12

Description of my issue

Hello !

In my python code, I’m importing the otb using the following :

import otbApplication as otb

After importing it, I’m trying to change the otb log level by changing the OTB_LOGGER_LEVEL environment variable, for example :

os.environ["OTB_LOGGER_LEVEL"] = "WARNING"

However, even if I try to change it to WARNING, it still keeps the INFO log level.

For now, our solution is to import the otbApplication as late as possible, but it makes our code quite unclean because we have an import throughout the code.

Do you have any idea about how being able to change this log level after importing otbApplication ?

Best regards,

Maël

Hi @mlucas ,

You need to declare this environment variable before importing otb, You can do it a line just before the import one, or declare the environment variable before running your python script.

This is not a ideal solution, currently I don’t know an other way to do that. As OTB was firstly used in command line or in library, this was the way to configure the log level and there is no other way when OTB is started.

Best regards

Okay, thank you for your answer !

Best regards

@neorne That’s exactly what I already said earlier