List logs

Demonstrates how to list the names of available Logs.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample

Node.js

To learn how to install and use the client library for Logging, see the Logging Client Libraries.

// Imports the Google Cloud client library
const {Logging} = require('@google-cloud/logging');

// Creates a client
const logging = new Logging();

async function printLogNames() {
  const [logs] = await logging.getLogs();
  console.log('Logs:');
  logs.forEach(log => {
    console.log(log.name);
  });
}
printLogNames();

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser