Go Language Log format output

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Go Language Log output

Bits or ' Ed together to control what's printed.//there is no control over the order they appear (the order listed//her e) or the format they present (as described in the comments).//The prefix is followed by a colon if llongfile or L shortfile//is specified.//For example, Flags Ldate | Ltime (or lstdflags) produce,//2009/01/23 01:23:23 message//while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,//2009/01/23 01:23:23.123123/a/b/c/d.go:23:messageldate = 1 << iota//the date in                 The local time Zone:2009/01/23ltime//The time in the local time zone:01:23:23lmicroseconds  Microsecond resolution:01:23:23.123123.                    Assumes Ltime.llongfile//full file name and line number:/a/b/c/d.go:23lshortfile Final file name element and line number:d.go:23. Overrides LLONGFILELUTC//if Ldate or Ltime is set, use UTC rather than the local time zoneLstdflags = Ldate | Ltime//Initial values for the standard logger

Ldate//Date: 2009/01/23
Ltime//Time: 01:23:23
Lmicroseconds//microseconds: 01:23:23.123123.
Llongfile//path + file name + line number:/a/b/c/d.go:23
Lshortfile//filename + line number: d.go:23
LUTC//using the standard UTC time Format
Lstdflags = Ldate | Ltime//default

Set Default:

log.SetFlags(log.LstdFlags)

Set the date, time, file name + line number (print error message, easier to locate the error point, problem location is useful)

log.SetFlags(log.LstdFlags | Lshortfile)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.