Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file-server: add flag to enable the access log #3454

Merged

Conversation

rgl
Copy link
Contributor

@rgl rgl commented May 26, 2020

This closes #3452.

Using --access-log as-in:

./caddy file-server --access-log

Will enable the default access log and caddy will start showing the http access log in the console:

2020/05/26 20:44:49.126	INFO	http.log.access	handled request	{"request": {"method": "GET", "uri": "/", "proto": "HTTP/1.1", "remote_addr": "[::1]:38556", "host": "localhost:8000", "headers": {"Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-Dest": ["document"], "Accept-Encoding": ["gzip, deflate, br"], "Accept-Language": ["en-US,en;q=0.9,pt-PT;q=0.8,pt;q=0.7"], "Connection": ["keep-alive"], "Upgrade-Insecure-Requests": ["1"], "User-Agent": ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"], "Sec-Fetch-User": ["?1"], "Cache-Control": ["max-age=0"], "Sec-Fetch-Site": ["cross-site"]}}, "common_log": "::1 - - [26/May/2020:21:44:49 +0100] \"GET / HTTP/1.1\" 200 15129", "duration": 0.001489366, "size": 15129, "status": 200, "resp_headers": {"Content-Type": ["text/html; charset=utf-8"], "Server": ["Caddy"]}}
2020/05/26 20:44:49.387	ERROR	http.log.access	handled request	{"request": {"method": "GET", "uri": "/favicon.ico", "proto": "HTTP/1.1", "remote_addr": "[::1]:38556", "host": "localhost:8000", "headers": {"Sec-Fetch-Dest": ["image"], "Referer": ["http://localhost:8000/"], "Accept-Encoding": ["gzip, deflate, br"], "Accept-Language": ["en-US,en;q=0.9,pt-PT;q=0.8,pt;q=0.7"], "Pragma": ["no-cache"], "Accept": ["image/webp,image/apng,image/*,*/*;q=0.8"], "Sec-Fetch-Site": ["same-origin"], "Sec-Fetch-Mode": ["no-cors"], "Connection": ["keep-alive"], "Cache-Control": ["no-cache"], "User-Agent": ["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"]}}, "common_log": "::1 - - [26/May/2020:21:44:49 +0100] \"GET /favicon.ico HTTP/1.1\" 404 0", "duration": 0.000366389, "size": 0, "status": 404, "resp_headers": {"Server": ["Caddy"]}}

@CLAassistant
Copy link

CLAassistant commented May 26, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful -- nice and simple, thanks!

@mholt mholt added this to the 2.1 milestone May 26, 2020
@mholt mholt merged commit aa20878 into caddyserver:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flag to enable file-server access log
3 participants