I am currently using cvxpy
for my project. When I solve an optimization problem, I have the option to turn the verbose flag on using prob.solve(solver=cvx.CVXOPT, verbose=True)
. When I do that, the logger starts printing the DEBUG level log messages to the console.
I understand that it is because of the following section in cvxpy
source code.
LOGGER = logging.getLogger("__cvxpy__")
LOGGER.propagate = False
LOGGER.setLevel(logging.INFO)
_stream_handler = logging.StreamHandler(sys.stdout)
_stream_handler.setLevel(logging.INFO)
_formatter = logging.Formatter(
fmt="(CVXPY) %(asctime)s: %(message)s", datefmt="%b %d %I:%M:%S %p"
)
_stream_handler.setFormatter(_formatter)
LOGGER.addHandler(_stream_handler)
How do I redirect the messages to a file without hacking the original source code? Can there be a setter method? TIA