def METHOD_NAME(proc_name, log_dir=None):
  """
  Configure logging for the program ``proc_name``:
    - Apply log.conf in the config directory.
    - If DESKTOP_LOGLEVEL environment variable is specified, the root console
      handler (stdout/stderr) is set to that level. If there is no console handler,
      a new one is created.
    - Defining the environment variable DESKTOP_DEBUG is the same as setting
      DESKTOP_LOGLEVEL=DEBUG.
  The ``log_dir`` will replace the %LOG_DIR% in log.conf. If not specified, we look
  for the DESTKOP_LOG_DIR environment variable, and then default to the DEFAULT_LOG_DIR.
  This removes all previously installed logging handlers.
  """
  global FORCE_DEBUG
  # Setup log_dir
  if not log_dir:
    log_dir = os.getenv("DESKTOP_LOG_DIR", DEFAULT_LOG_DIR)
  if not os.path.exists(log_dir):
    try:
      os.makedirs(log_dir)
    except OSError as err:
      print('Failed to create log directory "%s": %s' % (log_dir, err), file=sys.stderr)
      raise err
  # Remember where our log directory is
  global _log_dir
  _log_dir = log_dir
  log_conf = _read_log_conf(proc_name, log_dir)
  if log_conf is not None:
    logging.config.fileConfig(log_conf)
    root_logger = logging.getLogger()
  else:
    # Get rid of any preinstalled/default handlers
    root_logger = logging.getLogger()
    for h in root_logger.handlers:
      root_logger.removeHandler(h)
  # always keep DEBUG at the root, since we'll filter in the
  # handlers themselves - this allows the /logs endpoint
  # to always have all logs.
  root_logger.setLevel(logging.DEBUG)
  # Handle env variables
  env_loglevel = os.getenv("DESKTOP_LOGLEVEL")
  env_debug = os.getenv('DESKTOP_DEBUG') or FORCE_DEBUG
  if env_debug:
    env_loglevel = 'DEBUG'
  if env_loglevel:
    try:
      lvl = getattr(logging, env_loglevel.upper())
    except AttributeError:
      raise Exception("Invalid log level in DESKTOP_LOGLEVEL: %s" % (env_loglevel,))
    # Set the StreamHandler to the level (create one if necessary)
    handler = _find_console_stream_handler(root_logger)
    if not handler:
      handler = logging.StreamHandler()
      handler.setFormatter(logging.Formatter(LOG_FORMAT, DATE_FORMAT))
      root_logger.addHandler(handler)
    if handler:
      handler.setLevel(lvl)
    # Set all loggers but error.log to the same logging level
    for h in root_logger.__dict__['handlers']:
      if isinstance(h, (FileHandler, RotatingFileHandler)):
        if os.path.basename(h.baseFilename) != 'error.log':
          h.setLevel(lvl)
    # Set all loggers but error.log to the same logging level
    for h in root_logger.__dict__['handlers']:
      if isinstance(h, (SocketHandler)) and h.level != 40:
        h.setLevel(lvl)
    from desktop.conf import DATABASE_LOGGING
    if hasattr(DATABASE_LOGGING, 'get') and not DATABASE_LOGGING.get():
      def disable_database_logging():
        logger = logging.getLogger()
        logger.manager.loggerDict['django.db.backends'].level = 20 # INFO level
      disable_database_logging()