如何在生产模式下记录Beego的访问日志?

huangapple go评论71阅读模式
英文:

How make Beego log access in production mode?

问题

我在设置Beego的日志配置时遇到了一些问题,无法在生产模式下正确设置。在开发过程中,日志一直打印访问日志,但在生产环境中停止了。甚至404错误也没有打印出来。
我尝试将日志级别设置为Debug,并设置一个新的文件记录器,但仍然无法打印访问日志。

以下是代码示例:

func main() {
    runtime.GOMAXPROCS(8)
    beego.SetLevel(beego.LevelDebug)
    beego.SetLogger("file", `{"filename":"logs/test.log"}`)
    beego.Run()
}

对此有什么帮助吗?

英文:

I'm having some trouble to set the right log configuration in Beego for production mod. While developing the log keeps on printing access logs but in production it stop. Even 404 are not printed.
I tried to set the log level to Debug and set a new file logger but it still not printing access log.
<!-- language: go -->

func main() {
    runtime.GOMAXPROCS(8)
    beego.SetLevel(beego.LevelDebug)
    beego.SetLogger(&quot;file&quot;, `{&quot;filename&quot;:&quot;logs/test.log&quot;}`)
    beego.Run()
}

Any help with this?

答案1

得分: 2

主函数() {
beego.AccessLogs = true
beego.Run()
}

英文:
func main() {
    beego.AccessLogs = true
    beego.Run()
}

答案2

得分: 0

看起来Beego的开发者是有意这样做的。在生产模式下,Beego不会打印访问日志。在这里查看该问题:链接

英文:

It looks that the developers of Beego did this on purpose. Beego in production mode don't print access logs. Check the issue here.

答案3

得分: 0

关于最新的Beego,代码如下所示:

func main() {
    beego.BConfig.Log.AccessLogs = true
    beego.Run()
}

请注意,这是Beego的示例代码,用于启用访问日志记录。

英文:

As for latest Beego, it would look like this.

func main() {
    beego.BConfig.Log.AccessLogs = true
    beego.Run()
}

huangapple
  • 本文由 发表于 2015年2月6日 00:47:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/28349491.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定