diff --git a/logger/README.md b/logger/README.md index 4373170c7..a69d05b60 100644 --- a/logger/README.md +++ b/logger/README.md @@ -40,10 +40,11 @@ logger.SetLoggerLevel("warn") #### output to file -Add the file item under the logger option in the configuration file +Set `appender: file` and add the file item under the logger option in the configuration file. When the sample is run from `logger/rolling`, the relative file name below is created as `logger/rolling/logs.log`. Use `appender: console,file` if you want the same log records to be written to both console and file. ```yaml logger: + appender: file file: name: logs.log max-size: 1 diff --git a/logger/README_zh.md b/logger/README_zh.md index ce945eabd..ef471f3b7 100644 --- a/logger/README_zh.md +++ b/logger/README_zh.md @@ -40,10 +40,11 @@ logger.SetLoggerLevel("warn") #### 输出到文件 -在配置文件中的 logger 选项下添加 file 项 +在配置文件中的 logger 选项下设置 `appender: file` 并添加 file 项。从 `logger/rolling` 目录运行样例时,下面的相对文件名会生成到 `logger/rolling/logs.log`。如果希望同一批日志同时输出到控制台和文件,可使用 `appender: console,file`。 ```yaml logger: + appender: file file: name: logs.log max-size: 1 diff --git a/logger/rolling/cmd/main.go b/logger/rolling/cmd/main.go index 074fd8c33..ce7e415a7 100644 --- a/logger/rolling/cmd/main.go +++ b/logger/rolling/cmd/main.go @@ -44,6 +44,7 @@ func main() { logger.Info("hello dubbogo this is info log") logger.Debug("hello dubbogo this is debug log") logger.Warn("hello dubbogo this is warn log") + time.Sleep(time.Second * 1) } } } diff --git a/logger/rolling/conf/dubbogo.yml b/logger/rolling/conf/dubbogo.yml index d3738aa10..60e84d7bc 100644 --- a/logger/rolling/conf/dubbogo.yml +++ b/logger/rolling/conf/dubbogo.yml @@ -4,6 +4,7 @@ dubbo: name: tri port: 20000 logger: + appender: file file: name: logs.log max-size: 1