Skip to main content
Version: Next

LogClient

Client for accessing Actor run or build logs.

Provides methods to retrieve logs as text or stream them in real-time. Logs can be accessed for both running and finished Actor runs and builds.

Hierarchy

  • ResourceClient
    • LogClient
const client = new ApifyClient({ token: 'my-token' });
const runClient = client.run('my-run-id');

// Get the log content
const log = await runClient.log().get();
console.log(log);

// Get the log content as raw bytes
const logBuffer = await runClient.log().get({ buffer: true });

// Stream the log in real-time
const stream = await runClient.log().stream();
stream.on('line', (line) => console.log(line));

Index

Properties

inheritedapifyClient

apifyClient: ApifyClient

inheritedbaseUrl

baseUrl: string

inheritedhttpClient

httpClient: HttpClient

optionalinheritedid

id?: string

optionalinheritedparams

params?: Record<string, unknown>

inheritedpublicBaseUrl

publicBaseUrl: string

Added in 2.17.0

inheritedresourcePath

resourcePath: string

optionalinheritedsafeId

safeId?: string

inheritedurl

url: string

Methods

get

  • get(options): Promise<undefined | string>
  • get(options): Promise<undefined | Buffer<ArrayBufferLike>>
  • get(options): Promise<undefined | string | Buffer<ArrayBufferLike>>
  • Retrieves the log as a string.

    The buffer option only selects the return type: the bytes come back as a Buffer (Node.js) or ArrayBuffer (browser), not decoded to a string. Either way the whole log is downloaded in one response; to read it incrementally, use LogClient.stream.


    Parameters

    • optionaloptions: LogGetOptions & { buffer?: false }

      Log retrieval options.

    Returns Promise<undefined | string>

    The log content, or undefined if it does not exist. A chained client such as run.log() throws an ApifyApiError on a 404, since the run itself may be what is missing.

stream

  • stream(options): Promise<undefined | Readable>
  • Retrieves the log as a Readable stream. Only works in Node.js.


    Parameters

    Returns Promise<undefined | Readable>

    The log content as a Readable stream, or undefined if it does not exist. A chained client such as run.log() throws an ApifyApiError on a 404, since the run itself may be what is missing.