Getting Started
Request handling
- Routing
- Action Controller
- Resources
- Context
- Request Binding
- Middleware
- Error Handling
- Sessions
- Cookies
Frontend
Database
- Getting started with Pop
- Soda CLI
- Database Configuration
- Buffalo Integration
- Models
- Generators
- Migrations
- Fizz
- Mutations
- Querying
- Raw Queries
- Callbacks
- Scoping
- Associations and Relationships
- One to one associations
- One to many associations
Guides
- API Applications
- File Uploads
- Background Job Workers
- Mailers
- Tasks
- Plugins
- Local Authentication
- Third Party Authentication
- Events
- Go Modules
- Localization
- Logging
- Template Engines
- Testing
- Videos
Deploy
Logging
Guides
Logging
Buffalo logs are managed using the logrus package.
Defaults
The default logger outputs logs in a human-readable format:
INFO[2020-02-21T07:42:34+01:00] /en/ content_type=text/html duration=26.189949ms human_size="21 kB" method=GET params="{\"lang\":[\"en\"]}" path=/en/ render=22.730816ms request_id=9b8d9260225fe99609a2-7cc679f4ae458b9925e3 size=21182 status=200
Customize the logger
// JSONLogger wraps a logrus JSON logger into a buffalo Logger
func JSONLogger(lvl logger.Level) logger.FieldLogger {
l := logrus.New()
l.Level = lvl
l.SetFormatter(&logrus.JSONFormatter{})
l.SetOutput(os.Stdout)
return logger.Logrus{FieldLogger: l}
}
//...
app = buffalo.New(buffalo.Options{
// ...
Logger: JSONLogger(logger.DebugLevel),
}