Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1版本 server 的logger段配置问题 #1946

Closed
stevenyangecho opened this issue Jun 27, 2022 · 2 comments
Closed

2.1版本 server 的logger段配置问题 #1946

stevenyangecho opened this issue Jun 27, 2022 · 2 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version. inactive

Comments

@stevenyangecho
Copy link

1. What version of Go and system type/arch are you using?

go version go1.18 windows/amd64

2. What version of GoFrame are you using?

CLI Built Detail:
Go Version: go1.17.11
GF Version: v2.1.0
Git Commit: 2022-06-21 21:52:54 3b9e5c7
Build Time: 2022-06-21 22:04:44

https://goframe.org/pages/viewpage.action?pageId=44449484
有一个关于服务端logger的配置
我在本地 配置

[server]
address = ":800"
httpsAddr = ":443"
HTTPSCertPath = "server.crt"
HTTPSKeyPath = "server.key"
openapiPath = "/api.json"
swaggerPath = "/swagger"
logpath = "logs/server" # 日志文件路径。默认为空,表示关闭,仅输出到终端
logstdout = true # 日志是否同时输出到终端。默认true
errorLogEnabled = true
errorStack = true
errorLogPattern = "error.{Ymd}.log"
accessLogEnabled = true
accessLogPattern = "access.{Ymd}.log"
[server.logger]
path= "logs/server"
prefix = "" # 日志内容输出前缀。默认为空
file= "{Y-m-d}.log"
level = "all" # 日志输出级别
ctxKeys = [] # 自定义Context上下文变量名称,自动打印Context的变量到日志中。默认为空
rotateSize = 0 # 按照日志文件大小对文件进行滚动切分。默认为0,表示关闭滚动切分特性
rotateExpire = "7d" # 按照日志文件时间间隔对文件滚动切分。默认为0,表示关闭滚动切分特性
rotateBackupLimit = 0 # 按照切分的文件数量清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
rotateBackupExpire = "7d" # 按照切分的文件有效期清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除
rotateBackupCompress = 0 # 滚动切分文件的压缩比(0-9)。默认为0,表示不压缩
rotateCheckInterval = "5s" # 滚动切分的时间检测间隔,一般不需要设置。默认为1小时
stdoutColorDisabled = false # 关闭终端的颜色打印。默认开启
writerColorEnable = false # 日志文件是否带上颜色。默认false,表示不带颜色

build 运行 后会报错

2022-06-27 13:54:01.963 [FATA] {c87f03e57a64fc162ff14002b0c53cf2} exception recovered: runtime error: invalid memory address or nil pointer dereference

  1. exception recovered: runtime error: invalid memory address or nil pointer dereference

debug调试代码 发现

if err = server.SetConfigWithMap(serverConfigMap); err != nil {

这一行覆盖了 server 的config字段,导致 server.config.Logger.init 为nil. 从而导致程序出错

问题二

path= "logs/server"
prefix = "" # 日志内容输出前缀。默认为空
file= "{Y-m-d}.log"

这些字段似乎和 server 本身的

logpath = "logs/server" # 日志文件路径。默认为空,表示关闭,仅输出到终端
logstdout = true # 日志是否同时输出到终端。默认true
errorLogEnabled = true
errorLogPattern = "error.{Ymd}.log"
accessLogEnabled = true
accessLogPattern = "access.{Ymd}.log"

有重复?冲突? 有没有详细一点的解释呢

@glennliao
Copy link
Contributor

遇到了相同的问题,请问后续有如何处理吗

@gqcn gqcn added bug It is confirmed a bug, but don't worry, we'll handle it. wip labels Oct 11, 2022
@gqcn
Copy link
Member

gqcn commented Oct 11, 2022

@stevenyangecho @glennliao 不好意思我来晚了,我初步check了一下,是一个BUG,我优先修复一下,请骚等。

gqcn added a commit that referenced this issue Oct 11, 2022
gqcn added a commit that referenced this issue Oct 11, 2022
@gqcn gqcn added done This issue is done, which may be release in next version. and removed wip labels Oct 11, 2022
@gqcn gqcn closed this as completed Oct 11, 2022
gqcn added a commit that referenced this issue Oct 12, 2022
* fix issue #1946

* fix issue #1946
houseme added a commit to houseme/gf that referenced this issue Oct 13, 2022
* master: (29 commits)
  fix issue gogf#1946 (gogf#2194)
  fix issue of OmitEmptyWhere in Builder for package gdb (gogf#2195)
  fix: modify `Polaris` config readme.md (gogf#2186)
  fix info content when listens on port :0 for ghttp.Server (gogf#2191)
  fix: pgsql driver check local type error (gogf#2192)
  new version v2.2.0 (gogf#2185)
  feat: temporarily disable the unit testing of the Polaris configuration center (gogf#2183)
  package comments and readme update (gogf#2182)
  feat: create polaris config (gogf#2170)
  add function `ZipPathContent` for package `gcompress` (gogf#2179)
  feat: improve glog for polaris  register (gogf#2178)
  improve port listening for ghttp.Server (gogf#2175)
  add WithUUID for package gtrace (gogf#2176)
  fix issue gogf#1965 (gogf#2177)
  fix issue gogf#1965 (gogf#2174)
  fix issue gogf#2172 (gogf#2173)
  add `gcfg.Adapter` implements using apollo service (gogf#2165)
  add watch feature for package kubecm (gogf#2164)
  fix configuration management for package gdb (gogf#2163)
  add local db configuration support for package gdb (gogf#2161)
  ...

# Conflicts:
#	contrib/config/apollo/README.MD
#	contrib/config/apollo/apollo.go
#	contrib/config/kubecm/README.MD
#	contrib/config/kubecm/kubecm.go
#	contrib/drivers/README.MD
#	contrib/registry/polaris/go.mod
#	contrib/registry/polaris/go.sum
#	database/gdb/gdb_driver_wrapper_db.go
#	example/go.mod
#	example/go.sum
#	version.go
houseme pushed a commit that referenced this issue Oct 22, 2022
* fix issue #1946

* fix issue #1946
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. done This issue is done, which may be release in next version. inactive
Projects
None yet
Development

No branches or pull requests

3 participants