0
$\begingroup$

I'm trying to debug a qiskit circuit that won't "unroll." Looking at the source code, there are a log of logging calls but they aren't enabled. How can I enable logging in qiskit? Where is the log written?

$\endgroup$
1
  • $\begingroup$ Could you maybe provide some example code of the circuit you're working with and what you've tried so far? $\endgroup$
    – ryanhill1
    Jun 21, 2023 at 14:19

1 Answer 1

1
$\begingroup$

Qiskit uses standard Python logging which means all the logging calls you see in the source code go to Python's built-in logging infrastructure and how those get written out or displayed is configurable. The details on how to use it are documented here: https://docs.python.org/3/howto/logging.html

By default only log messages at the WARNING level or above will be displayed. If you'd like to see more of the logging messages you can run something like:

import logging

logging.basicConfig(level="DEBUG")

and that will print all the log messages to your console. If you'd like to write the log messages to a file you can run this instead:

import logging

logging.basicConfig(level="DEBUG", filename="output.log")

Nte you can only call basicConfig once as it sets the handler on the root logger and it won't override that by default, unless you set the argument force=True.

More details on the specifics of this around Qiskit's transpiler are documented here: https://qiskit.org/documentation/tutorials/circuits_advanced/04_transpiler_passes_and_passmanager.html#Transpiler-Logging

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.