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.

Set up the Golang API client

Before you begin, 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
Configure the 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. 👇
Parameter Description Required/Default
token Your log shipping token directs the data securely to your Log Management account. The default token is auto-populated in the examples when you’re logged into the app as an Admin. Manage your tokens. Replace <<LOG-SHIPPING-TOKEN>> with the token of the account you want to ship to. Required
SetUrl Listener URL and port. Replace <<LISTENER-HOST>> with the host for your region. For example, if your account is hosted on AWS US East, or if hosted on Azure West Europe. The required port depends whether HTTP or HTTPS is used: HTTP = 8070, HTTPS = 8071. Required (default:
SetDebug Debug flag. false
SetDrainDuration Time to wait between log draining attempts. 5 * time.Second
SetTempDirectory Filepath where the logs are buffered. --
SetCheckDiskSpace To enable SetDrainDiskThreshold, set to true. Otherwise, false. true
SetDrainDiskThreshold 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. 70.0
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