Logz.io Golang API client setup

This shipper uses goleveldb and goqueue as a persistent storage implementation of a persistent queue, so the shipper backs up your logs to the local file system before sending them. Logs are queued in the buffer and 100% non-blocking. A background Go routine ships the logs every 5 seconds.

You’ll need: Go 1.x or higher

Add the dependency to your project

Navigate to your project’s folder in the command line, and run this command to install the dependency.

go get -u github.com/logzio/logzio-go

Configure Logz.io Golang API client

Use the sample in the code block below as a starting point, and replace the sample with a configuration that matches your needs.

For a complete list of options, see the configuration parameters below the code block.👇

package main

import (

func main() {
  // Replace these parameters with your configuration
  l, err := logzio.New(
    logzio.SetDrainDuration(time.Second * 5),
  if err != nil {

  // Because you're configuring directly in the code,
  // you can paste the code sample here to send a test log.
  // The code sample is below the parameters list. 👇


Your Logz.io account token.
Replace <ACCOUNT-TOKEN> with the token of the account you want to ship to.
SetUrl https://listener.logz.io:8071
Listener URL and port.
Replace <LISTENER-URL> with your region’s listener URL. For more information on finding your account’s region, see Account region.
SetDebug false
Debug flag.
SetDrainDuration 5 * time.Second
Time to wait between log draining attempts.
Filepath where the logs are buffered.
SetCheckDiskSpace true
To enable SetDrainDiskThreshold, set to true. Otherwise, false.
SetDrainDiskThreshold 70.0
Maximum file system usage, in percent. Used only if SetCheckDiskSpace is set to true.
If the file system storage exceeds this threshold, buffering stops and new logs are dropped. Buffering resumes if used space drops below the threshold.

Code sample

msg := fmt.Sprintf("{\"%s\": \"%d\"}", "message", time.Now().UnixNano())
err = l.Send([]byte(msg))
if err != nil {

l.Stop() // Drains the log buffer