-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
Feature Proposal Description
The current logger middleware is using a custom log format. We should provide 4-5 standard log formats that are industry standard for users to use. This would allow the logs generated by Fiber
to be more easy to parse by standard logging/metrics tools.
We should include:
- Apache Common log format
- Apache Combined log format
- NGINX Style log format
- Fiber Default (Current)
- Common Log Format (CLF)
These should be defined in a format.go
file under the middleware.
Alignment with Express API
The apache common is the default format for expressjs/morgan
middleware.
HTTP RFC Standards Compliance
n/a
API Stability
Would allow fiber logs to be more easy to parse by industry standard tools.
Feature Examples
Generated log formats by `OpenAI - o1`. Need to be verified for accuracy.
// FormatCommonLog (CLF) is fully compliant with the “Common Log Format.”
var FormatCommonLog = "${ip} - - [${time}] \"${method} ${url} ${protocol}\" ${status} ${clfBytesSent}\n"
// FormatApacheCommon is basically CLF but usually doesn’t strictly require
// a dash for unknown content length. Often used by default in Apache.
var FormatApacheCommon = "${ip} - - [${time}] \"${method} ${url} ${protocol}\" ${status} ${bytesSent}\n"
// FormatApacheCombined extends the Apache Common to add referer and user-agent.
var FormatApacheCombined = "${ip} - - [${time}] \"${method} ${url} ${protocol}\" ${status} ${bytesSent} \"${referer}\" \"${ua}\"\n"
// FormatNginx is a typical Nginx-style format (like Combined).
var FormatNginx = "${ip} - - [${time}] \"${method} ${url} ${protocol}\" ${status} ${bytesSent} \"${referer}\" \"${ua}\"\n"
// FormatJSON is an example for JSON-based logging.
var FormatJSON = "{\"time\":\"${time}\",\"ip\":\"${ip}\",\"method\":\"${method}\",\"url\":\"${url}\",\"status\":${status},\"bytesSent\":${bytesSent}}\n"
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have searched for existing issues that describe my proposal before opening this one.
- I understand that a proposal that does not meet these guidelines may be closed without explanation.
edvardsanta