
**Apache Airflow version**: 2.0.0


**Kubernetes version (if you are using kubernetes)**: NA

**Environment**: Docker

- **OS**: CentOS Linux 7 (Core)
- **Python version**: 3.6.8

**What happened**:
Every time I call get_log api (https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_log) to get logs for a specific task instance that is not in the dag now, I get the TaskNotFound exception.

```Traceback (most recent call last):
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib64/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/security.py", line 47, in decorated
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/utils/session.py", line 65, in wrapper
    return func(*args, session=session, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/airflow/api_connexion/endpoints/log_endpoint.py", line 74, in get_log
    ti.task = dag.get_task(ti.task_id)
  File "/usr/local/lib/python3.6/site-packages/airflow/models/dag.py", line 1527, in get_task
    raise TaskNotFound(f"Task {task_id} not found")
airflow.exceptions.TaskNotFound: Task 0-1769e47c-5933-42f9-ac59-b59c7de13382 not found
```

**What you expected to happen**:

Even if the task is not in the dag now I expect to get its log in a past run.

**How to reproduce it**:
Create a dag with a few tasks and run it. Then remove a task from the dag and try to get the log of the removed task in the past run using the api.


**Anything else we need to know**:

The problem is that in https://github.com/apache/airflow/blob/master/airflow/api_connexion/endpoints/log_endpoint.py at line 73 there is a call to get the task from current dag without catching the TaskNotFound exception.

tests/api_connexion/endpoints/test_log_endpoint.py
self._create_dagrun(session)
        key = self.app.config["SECRET_KEY"]
        serializer = URLSafeSerializer(key)
        token = serializer.dumps({"download_logs": True})
        response = self.client.get(
            f"api/v1/dags/{self.DAG_ID}/dagRuns/TEST_DAG_RUN_ID/"
            f"taskInstances/{self.TASK_ID}/logs/1?token={token}",
            headers={'Accept': 'text/plain'},
            environ_overrides={'REMOTE_USER': "test"},
        )
        expected_filename = "{}/{}/{}/{}/1.log".format(
            self.log_dir, self.DAG_ID, self.TASK_ID, self.default_time.replace(':', '.')
        )
        assert 200 == response.status_code
        assert (
            response.data.decode('utf-8')
            == f"\n*** Reading local file: {expected_filename}\nLog for testing.\n"
        )
    @provide_session
    def test_get_logs_response_with_ti_equal_to_none(self, session):