> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Logs

> SDK methods to fetch logs for services, jobs, workflows, job runs, and pods on TrueFoundry.

## Methods

<Accordion title="get">
  Fetch logs for various workload components, including Services, Jobs, Workflows, Job Runs, and Pods. Logs are filtered based on the provided query parameters.

  #### Parameters

  <ParamField body="start_ts" type="typing.Optional[int]">
    Start timestamp for querying logs, in nanoseconds from the Unix epoch.
  </ParamField>

  <ParamField body="end_ts" type="typing.Optional[int]">
    End timestamp for querying logs, in nanoseconds from the Unix epoch.
  </ParamField>

  <ParamField body="limit" type="typing.Optional[int]">
    Max number of log lines to fetch
  </ParamField>

  <ParamField body="direction" type="typing.Optional[LogsSortingDirection]">
    [🔗 LogsSortingDirection](/docs/truefoundry_sdk/enums#logssortingdirection)

    Direction of sorting logs. Can be `asc` or `desc`
  </ParamField>

  <ParamField body="num_logs_to_ignore" type="typing.Optional[int]">
    Number of logs corresponding to the starting timestamp to be ignored.
  </ParamField>

  <ParamField body="application_id" type="typing.Optional[str]">
    Application ID
  </ParamField>

  <ParamField body="application_fqn" type="typing.Optional[str]">
    Application FQN
  </ParamField>

  <ParamField body="deployment_id" type="typing.Optional[str]">
    Deployment ID
  </ParamField>

  <ParamField body="job_run_name" type="typing.Optional[str]">
    Name of the Job Run for which to fetch logs.
  </ParamField>

  <ParamField body="pod_name" type="typing.Optional[str]">
    Name of Pod for which to fetch logs.
  </ParamField>

  <ParamField body="container_name" type="typing.Optional[str]">
    Name of the Container for which to fetch logs.
  </ParamField>

  <ParamField body="pod_names" type="typing.Optional[typing.Union[str, typing.Sequence[str]]]">
    List of pod names for which to fetch logs.
  </ParamField>

  <ParamField body="pod_names_regex" type="typing.Optional[str]">
    Regex pattern for pod names to fetch logs.
  </ParamField>

  <ParamField body="search_filters" type="typing.Optional[str]">
    JSON string containing array of search filters with string, type and operator
  </ParamField>

  <ParamField body="search_string" type="typing.Optional[str]">
    String that needs to be matched
  </ParamField>

  <ParamField body="search_type" type="typing.Optional[LogsSearchFilterType]">
    [🔗 LogsSearchFilterType](/docs/truefoundry_sdk/enums#logssearchfiltertype)

    Query filter type, `regex` `substring` `ignore_case_substring`
  </ParamField>

  <ParamField body="search_operator" type="typing.Optional[LogsSearchOperatorType]">
    [🔗 LogsSearchOperatorType](/docs/truefoundry_sdk/enums#logssearchoperatortype)

    Comparison operator for filter. `equal` or `not_equal`
  </ParamField>

  #### Returns

  <ResponseField name="GetLogsResponse" type="GetLogsResponse">
    [🔗 GetLogsResponse](/docs/truefoundry_sdk/types#getlogsresponse)

    Successfully retrieved logs for the workload
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.logs.get(
      start_ts="value",
      end_ts="value",
      limit=10,
      direction="value",
      num_logs_to_ignore="value",
      application_id="application_id_value",
      application_fqn="value",
      deployment_id="value",
      job_run_name="value",
      pod_name="value",
      container_name="value",
      pod_names="value",
      pod_names_regex="value",
      search_filters="value",
      search_string="value",
      search_type="value",
      search_operator="value",
  )
  ```
</Accordion>
