Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Revel log type


May 15, 2021 Revel



Revel supports four types of log information:

  • TRACE - Debugging information
  • INFO - General information
  • WARN - Warning message
  • ERROR - Error message

Here's an example of using logs in Revel:

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

The logger uses the go log by default .

The logger is configured in app.conf. For example:

app.name = sampleapp

[dev]
log.trace.output = stdout
log.info.output  = stdout
log.warn.output  = stderr
log.error.output = stderr

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

log.trace.flags  = 10
log.info.flags   = 10

[prod]
log.trace.output = off
log.info.output  = off
log.warn.output  = log/%(app.name)s.log
log.error.output = log/%(app.name)s.log

In a development environment:

  • Displays detailed logs
  • The info or trace information displays the information with a prefix defined in app.conf

In a production environment:

  • The info and trace logs are ignored
  • Warning and error messages are written to the log/sampleapp .log file

Modify the log format based on the tag constant. F or example, 01:23:23 /a/b/c/d.go:23 Message format, using the Ltime | Llongfile = 2 | 8 = 10

Development status:

  • If the log directory log does not exist, Revel automatically creates the log directory.