Giter VIP home page Giter VIP logo

zlog's Introduction

zlog

Name

zlog - enables query logging to standard output.

Description

replace default plugin log, use zap as zlog instance

Syntax

zlog

With no arguments, a query log entry is written to stdout in the common log format for all requests. Or if you want/need slightly more control:

zlog [NAMES...] [FORMAT]
  • NAMES is the name list to match in order to be logged
  • FORMAT is the log format to use (default is Common Log Format), {common} is used as a shortcut for the Common Log Format. You can also use {combined} for a format that adds the query opcode {>opcode} to the Common Log Format.

You can further specify the classes of responses that get logged:

zlog [NAMES...] [FORMAT] {
    class CLASSES...
}
  • CLASSES is a space-separated list of classes of responses that should be logged

The classes of responses have the following meaning:

  • success: successful response
  • denial: either NXDOMAIN or nodata responses (Name exists, type does not). A nodata response sets the return code to NOERROR.
  • error: SERVFAIL, NOTIMP, REFUSED, etc. Anything that indicates the remote server is not willing to resolve the request.
  • all: the default - nothing is specified. Using of this class means that all messages will be logged whatever we mix together with "all".

If no class is specified, it defaults to all.

Log Format

You can specify a custom log format with any placeholder values. Log supports both request and response placeholders.

The following place holders are supported:

  • {type}: qtype of the request
  • {name}: qname of the request
  • {class}: qclass of the request
  • {proto}: protocol used (tcp or udp)
  • {remote}: client's IP address, for IPv6 addresses these are enclosed in brackets: [::1]
  • {local}: server's IP address, for IPv6 addresses these are enclosed in brackets: [::1]
  • {size}: request size in bytes
  • {port}: client's port
  • {duration}: response duration
  • {rcode}: response RCODE
  • {rsize}: raw (uncompressed), response size (a client may receive a smaller response)
  • {>rflags}: response flags, each set flag will be displayed, e.g. "aa, tc". This includes the qr bit as well
  • {>bufsize}: the EDNS0 buffer size advertised in the query
  • {>do}: is the EDNS0 DO (DNSSEC OK) bit set in the query
  • {>id}: query ID
  • {>opcode}: query OPCODE
  • {common}: the default Common Log Format.
  • {combined}: the Common Log Format with the query opcode.
  • {/LABEL}: any metadata label is accepted as a place holder if it is enclosed between {/ and }, the place holder will be replaced by the corresponding metadata value or the default value - if label is not defined. See the metadata plugin for more information.

The default Common Log Format is:

`{remote}:{port} - {>id} "{type} {class} {name} {proto} {size} {>do} {>bufsize}" {rcode} {>rflags} {rsize} {duration}`

Each of these logs will be outputted with log.Infof, so a typical example looks like this:

[INFO] [::1]:50759 - 29008 "A IN example.org. udp 41 false 4096" NOERROR qr,rd,ra,ad 68 0.037990251s

Examples

Log all requests to stdout

. {
    zlog
    whoami
}

Custom log format, for all zones (.)

. {
    zlog . "{proto} Request: {name} {type} {>id}"
}

Only log denials (NXDOMAIN and nodata) for example.org (and below)

. {
    zlog example.org {
        class denial
    }
}

Log all queries which were not resolved successfully in the Combined Log Format.

. {
    zlog . {combined} {
        class denial error
    }
}

Log all queries on which we did not get errors

. {
    zlog . {
        class denial success
    }
}

Also the multiple statements can be OR-ed, for example, we can rewrite the above case as following:

. {
    zlog . {
        class denial
        class success
    }
}

zlog's People

Contributors

yylt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.