Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

该示例中使用glog.Debug方法输出调试信息,3秒后关闭调试信息的输出。执行后,输出结果如下,可以看到只输出了3条日志信息,后续的调试日志信息由于通过SetDebug方法关闭后,便不再输出。

Code Block
languagego
2022-01-05 15:59:05.674 [DEBU] 2022-01-05 15:59:

...

05 
2022-01-05 15:59:05.675 [INFO] 2022-01-05 15:59:

...

05 
2022-01-05 15:59:06.684 [DEBU] 2022-01-05 15:59:

...

06 
2022-01-05 15:59:06.684 [INFO] 2022-01-05 15:59:

...

06 
2022-01-05 15:59:07.692 [DEBU] 2022-01-05 15:59:

...

07 
2022-01-05 15:59:07.692 [INFO] 2022-01-05 15:59:

...

07 
2022-01-05 15:59:08.708 [INFO] 2022-01-05 15:59:

...

08 
2022-01-05 15:59:09.717 [INFO] 2022-01-05 15:59:

...

09 
2022-01-05 15:59:10.728 [INFO] 2022-01-05 15:59:

...

10 
2022-01-05 15:59:11.733 [INFO] 2022-01-05 15:59:

...

11


我们还可以通过命令行参数或者系统环境变量参数的方式关闭掉调试信息。

  1. 修改命令行启动参数 - gf.glog.debug=false
  2. 修改指定的环境变量 - GF_GLOG_DEBUG=false