<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read_value(self, key, filepath=None, filename=None):
 """ Tries to read the value of given key from JSON file filename. :param filepath: Path to file :param filename: Name of file :param key: Key to search for :return: Value corresponding to given key :raises OSError, EnvironmentError, KeyError """

        path = filepath if filepath else self.filepath
        name = filename if filename else self.filename
        name = self._ends_with(name, ".json")
        path = self._ends_with(path, os.path.sep)

        try:
            output = self._read_json(path, name)
            if key not in output:
                raise KeyError("Key '{}' not found in file {}".format(key, filename))
            else:
                return output[key]
        except EnvironmentError as error:
            self.logger.error("Error while opening or reading the file: {}".format(error))
            raise