Repository: sanic-org/sanic

Issue:
Do not override log configuration
Hello.

Can you optionalize the `logging.config.dictConfig` in `app.py`? My application already have a comprehensive log configuration (and does not use log conf), I don't need to change it.

For the moment, my workaround is to override the `Sanic` class:
```

class UseMyLoggingSanic(Sanic):

    def __init__(self, name=None, router=None, error_handler=None,
                 load_env=True, request_class=None,
                 strict_slashes=False):

        from collections import deque, defaultdict
        from inspect import stack, getmodulename
        from sanic.router import Router
        from sanic.handlers import ErrorHandler
        from sanic.config import Config

        # Get name from previous stack frame
        if name is None:
            frame_records = stack()[1]
            name = getmodulename(frame_records[1])

        # logging
        # logging.config.dictConfig(log_config or LOGGING_CONFIG_DEFAULTS)
        self.log_config = None

        self.name = name
        self.router = router or Router()
        self.request_class = request_class
        self.error_handler = error_handler or ErrorHandler()
        self.config = Config(load_env=load_env)
        self.request_middleware = deque()
        self.response_middleware = deque()
        self.blueprints = {}
        self._blueprint_order = []
        self.debug = None
        self.sock = None
        self.strict_slashes = strict_slashes
        self.listeners = defaultdict(list)
        self.is_running = False
        self.is_request_stream = False
        self.websocket_enabled = False
        self.websocket_tasks = set()

        # Register alternative method names
        self.go_fast = self.run
```

This way, logs are routed correctly in my debug terminal, and not twice


Discussion:
You can pass in your own configuration. or are you saying you have log in another layer of your architecture ? 

You can disable access_log by `app.run(access_log=False)`.
Yes, I have a configuration module that handle the logging config on its own. I now simply call ```Sanic(__name__, log_config=None)`` and log are disabled, but I don't have any access log from sanic at all. Can't you just optionialize the call to 
```
logging.config.dictConfig(log_config or LOGGING_CONFIG_DEFAULTS)
```
?

Resolving patch:
diff --git a/sanic/app.py b/sanic/app.py
--- a/sanic/app.py
+++ b/sanic/app.py
@@ -28,7 +28,8 @@ class Sanic:
 
     def __init__(self, name=None, router=None, error_handler=None,
                  load_env=True, request_class=None,
-                 strict_slashes=False, log_config=None):
+                 strict_slashes=False, log_config=None,
+                 configure_logging=True):
 
         # Get name from previous stack frame
         if name is None:
@@ -36,7 +37,8 @@ def __init__(self, name=None, router=None, error_handler=None,
             name = getmodulename(frame_records[1])
 
         # logging
-        logging.config.dictConfig(log_config or LOGGING_CONFIG_DEFAULTS)
+        if configure_logging:
+            logging.config.dictConfig(log_config or LOGGING_CONFIG_DEFAULTS)
 
         self.name = name
         self.router = router or Router()
@@ -47,6 +49,7 @@ def __init__(self, name=None, router=None, error_handler=None,
         self.response_middleware = deque()
         self.blueprints = {}
         self._blueprint_order = []
+        self.configure_logging = configure_logging
         self.debug = None
         self.sock = None
         self.strict_slashes = strict_slashes
@@ -793,7 +796,7 @@ def _helper(self, host=None, port=None, debug=False,
             listeners = [partial(listener, self) for listener in listeners]
             server_settings[settings_name] = listeners
 
-        if debug:
+        if self.configure_logging and debug:
             logger.setLevel(logging.DEBUG)
         if self.config.LOGO is not None:
             logger.debug(self.config.LOGO)


Test patch: