Python 3.5.2 logger configuration and usage
<p>I'm new to python and trying to setup a logger in my simple app.</p>

<p>This is the app structure:</p>

<pre><code> - checker
      - checking
         - proxy_checker.py
      - custom_threading
         - __init__.py
         - executor_my.py
         - long_task.py
      - tests
      - __init__.py
      - logging_config.ini
      - main.py
</code></pre>

<p>i'm trying to setup the file configured logger 
in the main module's <code>checker/__init__.py</code><strong>:</strong></p>

<pre><code>from logging.config import fileConfig

fileConfig('logging_config.ini')
</code></pre>

<p><strong>logging_config.ini</strong></p>

<pre><code>[loggers]
keys=root

[handlers]
keys=stream_handler

[formatters]
keys=formatter

[logger_root]
level=DEBUG
handlers=stream_handler

[handler_stream_handler]
class=StreamHandler
level=DEBUG
formatter=formatter
args=(sys.stderr,)

[formatter_formatter]
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s
</code></pre>

<p>and the use it in the <code>/checker/custom_threading/exector_my.py</code>:</p>

<pre><code>import concurrent.futures
import logging

from custom_threading.long_task import LongTask


class MyExecutor(object):
    logger = logging.getLogger(__name__)
    _executor = concurrent.futures.ThreadPoolExecutor(max_workers=500)

    def __init__(self, thread_count, task):
        self._thread_count = thread_count
        self._task = LongTask(task)
        pass

    def start(self):
        self.logger.debug("Launching with thread count: " + str(self._thread_count))

*more irrelevant code*
</code></pre>

<p>tried to use logger.info / logger.debug.
for both options <strong>i don't get any error and nothing is logged in console</strong>. What do i do wrong?</p>

<p>P.S. maybe also useful that i run it on Win 10 x64</p>

<p>My (possibly wrong :-) guess is that you start the script by something like <code>python checker/main.py</code>, thus the logging configuration in <code>__init__.py</code> is not executed.</p>

<p>Please, take a look at this answer:
<a href="http://stackoverflow.com/questions/7533480/why-is-init-py-not-being-called">Why is __init__.py not being called?</a></p>

<p>Moreover, you need to ensure that <code>fileConfig()</code> is called before <code>getLogger()</code> (class body is executed at the time of import). A working setup would be to load the configuration somewhere at the beginning of <code>main.py</code> and instantiate the logger in <code>MyExecutor.__init__()</code>.</p>

python python-3.x logging