Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
May 28, 2020

README.md

Formtted Encoder Module for Caddy's Logger

This plugin adds logging encoder named formatted. The module accepts a template with the placeholders are surrounded by braces {} and filled by values extracted from the stucture of the JSON log encoder. The JSON configuration looks like this:

{
	"encoder": "formatted",
	"template": "{...}"
}

The nesting is traversed using >. For example, to print the uri field, the traversal is templated as {request>uri}.

{
	"request": {
		"method": "GET",
		"uri": "/",
		"proto": "HTTP/2.0",
		...
}

The Caddyfile configuration accepts the template immediately following the encoder name, and can be ommitted to assume Apache Common Log Format.

log {
	format formatted <template>
}

Install

First, the xcaddy command:

$ go get -u github.com/caddyserver/xcaddy/cmd/xcaddy

Then build Caddy with this Go module plugged in. For example:

$ xcaddy build --with github.com/caddyserver/format-encoder

About

Log encoder module for custom log formats

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.