I have built a python library that uses C# code(which is built and stored as a dll), using pythonnet. In that library, I generate logs using the python logger.

mylibrary.py

logger = logging.getLogger('mylibrary') logger.info('logging from my library')

The root logger is configured from the user code. For example, the handlers for the root logger is set by the user using logger's "addhandler()" method specifying the format, output file etc. Inside my library, I just log (logger.info()...) without configuring anything and the root handler set by the user takes care of writing this to the file.

usercode.py

root_logger = getLogger() root_logger.addHandler(FileHandler('abc.log')) root_handler.setFormat(...)

The user can control what my library can log by setting the level of the logger used by my library. The line below in usercode.py sets the logging level of my library's logger to critical so that the library can't log anything below it (logger.info() won't get into abc.log).

getLogger('mylibrary').setLevel(CRITICAL)

The problem comes now. Since I am using C# code in my library,

I want to capture the C# logs into abc.log I also want to configure the C# log just like I did for python logs

So the the line

getLogger('mylibrary').setLevel(CRITICAL)

in usercode.py should now make sure that only the critical logs in both the python as well as C# get into abc.log

Is there a way to achieve this?