'Reset logger to its initial state'

def _set_defaults(self):

    if self.warnings_logging_enabled():
        self.disable_warnings_logging()
    if self.exception_logging_enabled():
        self.disable_exception_logging()
    for handler in self.handlers[:]:
        self.removeHandler(handler)
    self.setLevel(conf.log_level)
    sh = StreamHandler()
    self.addHandler(sh)
    if conf.log_to_file:
        log_file_path = conf.log_file_path
        try:
            _ASTROPY_TEST_
            testing_mode = True
        except NameError:
            testing_mode = False
        try:
            if ((log_file_path == '') or testing_mode):
                log_file_path = os.path.join(_config.get_config_dir(), 'astropy.log')
            else:
                log_file_path = os.path.expanduser(log_file_path)
            fh = logging.FileHandler(log_file_path)
        except (IOError, OSError) as e:
            warnings.warn('log    file    {0!r}    could    not    be    opened    for    writing:    {1}'.format(log_file_path, text_type(e)), RuntimeWarning)
        else:
            formatter = logging.Formatter(conf.log_file_format)
            fh.setFormatter(formatter)
            fh.setLevel(conf.log_file_level)
            self.addHandler(fh)
    if conf.log_warnings:
        self.enable_warnings_logging()
    if conf.log_exceptions:
        self.enable_exception_logging()
