Skip to content
goodsign edited this page Feb 7, 2013 · 4 revisions
  • Message context:
    • %Level - log level (Trace, Debug, Info, Warn, Error, Critical)
    • %Lev - short log level (Trc, Dbg, Inf, Wrn, Err, Crt)
    • %LEVEL - capitalized log level (TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL)
    • %LEV - short capitalized log level (TRC, DBG, INF, WRN, ERR, CRT)
    • %l - super compact log level (t, d, i, w, e, c)
    • %Msg - message text (string)
    • %FullPath - full caller file path
    • %File - caller filename only
    • %RelFile - caller path relative to the application runtime directory
    • %Func - caller function name
    • %FuncShort - caller function name part after the last dot
  • Date and time
    • %Ns - time.Now().UnixNano()
    • %Date - shortcut for ‘2006-01-02’
    • %Time - shortcut for ‘15:04:05’
    • %Date(...) - date with format, specified in parentheses. Uses standard time.Format, so check http://golang.org/src/pkg/time/format.go for identifiers list. Use it like that: "%Date(2006-01-02)" (or any other format)
  • Special symbols
    • %n - newline
    • %t - tab

Predefined formats

Full name of a format identifier consists of the prefix std: and one of the identifiers listed below. Here is a full list of id-format pairs:

  • xml-debug: <time>%Ns</time><lev>%Lev</lev><msg>%Msg</msg><path>%RelFile</path><func>%Func</func>
  • xml-debug-short: <t>%Ns</t><l>%l</l><m>%Msg</m><p>%RelFile</p><f>%Func</f>
  • xml: <time>%Ns</time><lev>%Lev</lev><msg>%Msg</msg>
  • xml-short: <t>%Ns</t><l>%l</l><m>%Msg</m>
  • json-debug: {"time":%Ns,"lev":"%Lev","msg":"%Msg","path":"%RelFile","func":"%Func"}
  • json-debug-short: {"t":%Ns,"l":"%Lev","m":"%Msg","p":"%RelFile","f":"%Func"}
  • json: {"time":%Ns,"lev":"%Lev","msg":"%Msg"}
  • json-short: {"t":%Ns,"l":"%Lev","m":"%Msg"}
  • debug: [%LEVEL] %RelFile:%Func %Date %Time %Msg%n
  • debug-short: [%LEVEL] %Date %Time %Msg%n
  • fast: %Ns %l %Msg%n