Revel provides four loggers:

  • TRACE - debugging information only.
  • INFO - informational.
  • WARN - something unexpected but not harmful.
  • ERROR - someone should take a look at this.

Example usage:

now := time.Now()
revel.TRACE.Printf("%s", now.String())

Each of these is a variable to a default go logger.

Loggers may be configured in app.conf. Here is an example: = sampleapp

log.trace.output = stdout  = stdout
log.warn.output  = stderr
log.error.output = stderr

log.trace.prefix = "TRACE "  = "INFO  "

log.trace.flags  = 10   = 10

log.trace.output = off  = off
log.warn.output  = log/%(
log.error.output = log/%(

In dev mode:

  • even the most detailed logs will be shown.
  • everything logged at info or trace will be prefixed with its logging level.
  • default logger flag is 19 (Ldate|Ltime|Lshortfile)

In prod mode:

  • info and trace logs are ignored.
  • both warnings and errors are appended to the log/sampleapp.log file.
  • default logger flag is 3 (Ldate|Ltime)

To specify logger flags, you must calculate the flag value from the flag constants. For example, to the format 01:23:23 /a/b/c/d.go:23 Message requires the flags Ltime | Llongfile = 2 | 8 = 10.

Note: Revel creates the log directory if it does not already exists and if it’s not a absolute path then it prefix the Revel base path.

For example:

#Revel Base Path:

# and log config is
log.warn.output  = log/%(

# Result of log location is

Turn Off Colorize

Revel provides a way to turn of the colorize in the logger.

log.colorize = false

Default: true

Request Access Log

Revel provides request access log since v0.13, you can set the output viaapp.conf. Request log will have following values of RequestStartTime, ClientIP, ResponseStatus, RequestLatency, HTTPMethod and URLPath.

Sample output:

2016/05/25 18:17:17.806 200  162.269µs GET /
2016/05/25 18:17:17.810 200  204.896µs GET /public/css/bootstrap.css
2016/05/25 18:17:17.811 200  108.862µs GET /public/js/jquery-1.9.1.min.js

For Example:

log.request.output = log/%(

  • Issues tagged with log
GoDoc Reference
GitHub Labels