Basic logging
The simplest way to get started is to create a logger and log some messages.Always call
logger.Close() before your application exits to ensure asynchronous logs are flushed. Use defer to guarantee cleanup.Logging with fields
Standard interface (loosely typed)
Use the standard interface when you want clean, minimal code. It accepts loosely typed key-value pairs.LogFields API (strongly typed)
Use theLogFields API when performance and type safety are critical. This approach uses strongly typed fields to eliminate memory allocations caused by interface boxing.
Log levels
Velo supports standard log levels. Use the convenience methods for cleaner code:Creating contextual loggers
UseWith() or WithFields() to create a child logger with preset fields:
Using with Go’s slog
If you use Go’s standard structured logging library, you can configure Velo as yourslog.Handler:
Advanced configuration
For production use, configure Velo with async mode and JSON formatting:Available field types
When using the strongly typed API, Velo provides these field constructors:velo.String(key, value)- String valuesvelo.Int(key, value)- Integer valuesvelo.Duration(key, value)- Time durationsvelo.Bool(key, value)- Boolean valuesvelo.Float64(key, value)- Floating point valuesvelo.Time(key, value)- Timestampsvelo.Error(err)- Error values- And many more…
See the field constructors in the source code for the complete list of available types.
Next steps
Configuration options
Explore all available configuration options in the Options struct
Performance tuning
Learn about buffer sizes, overflow strategies, and optimization techniques