Repository: go-kratos/kratos
Pull request #2053 (2022-05-26 15:10:18)

build(deps): bump github.com/aliyun/aliyun-log-go-sdk from 0.1.35 to 0.1.36 in /contrib/log/aliyun
Bumps [github.com/aliyun/aliyun-log-go-sdk](https://github.com/aliyun/aliyun-log-go-sdk) from 0.1.35 to 0.1.36.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/aliyun/aliyun-log-go-sdk/releases">github.com/aliyun/aliyun-log-go-sdk's releases</a>.</em></p>
<blockquote>
<h2>v0.1.36</h2>
<h1>refine</h1>
<ol>
<li>add sts token for consumer <a href="https://github-redirect.dependabot.com/aliyun/aliyun-log-go-sdk/issues/160">#160</a></li>
</ol>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/aliyun/aliyun-log-go-sdk/commit/b8d79e0f5b53d28f2588cce6159080ddd10e794a"><code>b8d79e0</code></a> [add] comment for consumer</li>
<li><a href="https://github.com/aliyun/aliyun-log-go-sdk/commit/f376a451f569a07e82413acfc8af3a05e0a3ee72"><code>f376a45</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/aliyun/aliyun-log-go-sdk/issues/160">#160</a> from ayanamist/master</li>
<li><a href="https://github.com/aliyun/aliyun-log-go-sdk/commit/8d1f21268647b98d75c3c04cd63ea8cc9ae12c47"><code>8d1f212</code></a> consumer support SecurityToken</li>
<li><a href="https://github.com/aliyun/aliyun-log-go-sdk/commit/151f58ca1b656f21952fa32a86281e3b697ef9ee"><code>151f58c</code></a> add startingPosition/startingUnixtime for etljob (<a href="https://github-redirect.dependabot.com/aliyun/aliyun-log-go-sdk/issues/159">#159</a>)</li>
<li>See full diff in <a href="https://github.com/aliyun/aliyun-log-go-sdk/compare/v0.1.35...v0.1.36">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/aliyun/aliyun-log-go-sdk&package-manager=go_modules&previous-version=0.1.35&new-version=0.1.36)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index a005ccab..a100e19c 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -11,7 +11,7 @@ jobs:
 
     steps:
     - name: Checkout repo
-      uses: actions/checkout@v2
+      uses: actions/checkout@v3
 
     - name: Initialize CodeQL
       uses: github/codeql-action/init@v2
diff --git a/.github/workflows/gitee-sync.yml b/.github/workflows/gitee-sync.yml
index debfbb84..843b2819 100644
--- a/.github/workflows/gitee-sync.yml
+++ b/.github/workflows/gitee-sync.yml
@@ -12,7 +12,7 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout source code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v3
       - name: Mirror Github to Gitee
         uses: Yikun/hub-mirror-action@v1.2
         with:
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index c1cf783e..3fea4feb 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -41,9 +41,9 @@ jobs:
           - 8090:8090
           - 8091:8091
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
       - name: Set up Go
-        uses: actions/setup-go@v2
+        uses: actions/setup-go@v3.2.0
         with:
           go-version: ${{ matrix.go }}
 
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a5c3a0b2..b8f4c247 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -15,7 +15,7 @@ jobs:
       matrix: ${{ steps.set-matrix.outputs.matrix }}
     steps:
       - name: Checkout Repo
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
 
       - id: set-matrix
         run: ./hack/resolve-modules.sh
@@ -27,9 +27,9 @@ jobs:
     strategy:
       matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
       - name: Lint
-        uses: golangci/golangci-lint-action@v2
+        uses: golangci/golangci-lint-action@v3
         with:
           version: latest
           working-directory: ${{ matrix.workdir }}
diff --git a/app.go b/app.go
index 7a1ed446..df992250 100644
--- a/app.go
+++ b/app.go
@@ -31,7 +31,7 @@ type App struct {
 	opts     options
 	ctx      context.Context
 	cancel   func()
-	lk       sync.Mutex
+	mu       sync.Mutex
 	instance *registry.ServiceInstance
 }
 
@@ -39,7 +39,6 @@ type App struct {
 func New(opts ...Option) *App {
 	o := options{
 		ctx:              context.Background(),
-		logger:           log.NewHelper(log.GetLogger()),
 		sigs:             []os.Signal{syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT},
 		registrarTimeout: 10 * time.Second,
 		stopTimeout:      10 * time.Second,
@@ -50,6 +49,9 @@ func New(opts ...Option) *App {
 	for _, opt := range opts {
 		opt(&o)
 	}
+	if o.logger != nil {
+		log.SetLogger(o.logger)
+	}
 	ctx, cancel := context.WithCancel(o.ctx)
 	return &App{
 		ctx:    ctx,
@@ -72,10 +74,10 @@ func (a *App) Metadata() map[string]string { return a.opts.metadata }
 
 // Endpoint returns endpoints.
 func (a *App) Endpoint() []string {
-	if a.instance == nil {
-		return []string{}
+	if a.instance != nil {
+		return a.instance.Endpoints
 	}
-	return a.instance.Endpoints
+	return nil
 }
 
 // Run executes all OnStart hooks registered with the application's Lifecycle.
@@ -84,6 +86,9 @@ func (a *App) Run() error {
 	if err != nil {
 		return err
 	}
+	a.mu.Lock()
+	a.instance = instance
+	a.mu.Unlock()
 	eg, ctx := errgroup.WithContext(NewContext(a.ctx, a))
 	wg := sync.WaitGroup{}
 	for _, srv := range a.opts.servers {
@@ -107,9 +112,6 @@ func (a *App) Run() error {
 		if err := a.opts.registrar.Register(rctx, instance); err != nil {
 			return err
 		}
-		a.lk.Lock()
-		a.instance = instance
-		a.lk.Unlock()
 	}
 	c := make(chan os.Signal, 1)
 	signal.Notify(c, a.opts.sigs...)
@@ -120,7 +122,6 @@ func (a *App) Run() error {
 				return ctx.Err()
 			case <-c:
 				if err := a.Stop(); err != nil {
-					a.opts.logger.Errorf("failed to stop app: %v", err)
 					return err
 				}
 			}
@@ -134,9 +135,9 @@ func (a *App) Run() error {
 
 // Stop gracefully stops the application.
 func (a *App) Stop() error {
-	a.lk.Lock()
+	a.mu.Lock()
 	instance := a.instance
-	a.lk.Unlock()
+	a.mu.Unlock()
 	if a.opts.registrar != nil && instance != nil {
 		ctx, cancel := context.WithTimeout(NewContext(a.ctx, a), a.opts.registrarTimeout)
 		defer cancel()
diff --git a/config/config.go b/config/config.go
index fa8aa430..126a6379 100644
--- a/config/config.go
+++ b/config/config.go
@@ -7,13 +7,12 @@ import (
 	"sync"
 	"time"
 
-	"github.com/go-kratos/kratos/v2/log"
-
 	// init encoding
 	_ "github.com/go-kratos/kratos/v2/encoding/json"
 	_ "github.com/go-kratos/kratos/v2/encoding/proto"
 	_ "github.com/go-kratos/kratos/v2/encoding/xml"
 	_ "github.com/go-kratos/kratos/v2/encoding/yaml"
+	"github.com/go-kratos/kratos/v2/log"
 )
 
 var (
@@ -43,13 +42,11 @@ type config struct {
 	cached    sync.Map
 	observers sync.Map
 	watchers  []Watcher
-	log       *log.Helper
 }
 
 // New new a config with options.
 func New(opts ...Option) Config {
 	o := options{
-		logger:   log.GetLogger(),
 		decoder:  defaultDecoder,
 		resolver: defaultResolver,
 	}
@@ -59,7 +56,6 @@ func New(opts ...Option) Config {
 	return &config{
 		opts:   o,
 		reader: newReader(o),
-		log:    log.NewHelper(o.logger),
 	}
 }
 
@@ -67,20 +63,20 @@ func (c *config) watch(w Watcher) {
 	for {
 		kvs, err := w.Next()
 		if errors.Is(err, context.Canceled) {
-			c.log.Infof("watcher's ctx cancel : %v", err)
+			log.Infof("watcher's ctx cancel : %v", err)
 			return
 		}
 		if err != nil {
 			time.Sleep(time.Second)
-			c.log.Errorf("failed to watch next config: %v", err)
+			log.Errorf("failed to watch next config: %v", err)
 			continue
 		}
 		if err := c.reader.Merge(kvs...); err != nil {
-			c.log.Errorf("failed to merge next config: %v", err)
+			log.Errorf("failed to merge next config: %v", err)
 			continue
 		}
 		if err := c.reader.Resolve(); err != nil {
-			c.log.Errorf("failed to resolve next config: %v", err)
+			log.Errorf("failed to resolve next config: %v", err)
 			continue
 		}
 		c.cached.Range(func(key, value interface{}) bool {
@@ -104,22 +100,22 @@ func (c *config) Load() error {
 			return err
 		}
 		for _, v := range kvs {
-			c.log.Debugf("config loaded: %s format: %s", v.Key, v.Format)
+			log.Debugf("config loaded: %s format: %s", v.Key, v.Format)
 		}
 		if err = c.reader.Merge(kvs...); err != nil {
-			c.log.Errorf("failed to merge config source: %v", err)
+			log.Errorf("failed to merge config source: %v", err)
 			return err
 		}
 		w, err := src.Watch()
 		if err != nil {
-			c.log.Errorf("failed to watch config source: %v", err)
+			log.Errorf("failed to watch config source: %v", err)
 			return err
 		}
 		c.watchers = append(c.watchers, w)
 		go c.watch(w)
 	}
 	if err := c.reader.Resolve(); err != nil {
-		c.log.Errorf("failed to resolve config source: %v", err)
+		log.Errorf("failed to resolve config source: %v", err)
 		return err
 	}
 	return nil
diff --git a/config/options.go b/config/options.go
index 0f584a70..e89a6fca 100644
--- a/config/options.go
+++ b/config/options.go
@@ -22,7 +22,6 @@ type options struct {
 	sources  []Source
 	decoder  Decoder
 	resolver Resolver
-	logger   log.Logger
 }
 
 // WithSource with config source.
@@ -51,10 +50,9 @@ func WithResolver(r Resolver) Option {
 }
 
 // WithLogger with config logger.
+// Deprecated: use global logger instead.
 func WithLogger(l log.Logger) Option {
-	return func(o *options) {
-		o.logger = l
-	}
+	return func(o *options) {}
 }
 
 // defaultDecoder decode config from source KeyValue
diff --git a/config/reader.go b/config/reader.go
index 1410780e..6858a0f6 100644
--- a/config/reader.go
+++ b/config/reader.go
@@ -8,6 +8,8 @@ import (
 	"strings"
 	"sync"
 
+	"github.com/go-kratos/kratos/v2/log"
+
 	"github.com/imdario/mergo"
 	"google.golang.org/protobuf/encoding/protojson"
 	"google.golang.org/protobuf/proto"
@@ -45,9 +47,11 @@ func (r *reader) Merge(kvs ...*KeyValue) error {
 	for _, kv := range kvs {
 		next := make(map[string]interface{})
 		if err := r.opts.decoder(kv, next); err != nil {
+			log.Errorf("Failed to config decode error: %v key: %s value: %s", err, kv.Key, string(kv.Value))
 			return err
 		}
 		if err := mergo.Map(&merged, convertMap(next), mergo.WithOverride); err != nil {
+			log.Errorf("Failed to config merge error: %v key: %s value: %s", err, kv.Key, string(kv.Value))
 			return err
 		}
 	}
diff --git a/contrib/config/apollo/README.md b/contrib/config/apollo/README.md
index c07b67ec..c03cff0f 100644
--- a/contrib/config/apollo/README.md
+++ b/contrib/config/apollo/README.md
@@ -55,9 +55,6 @@ func WithEnableBackup() Option
 // specify apollo endpoint, such as http://localhost:8080
 func WithEndpoint(endpoint string) Option
 
-// inject a logger to debug
-func WithLogger(logger log.Logger) Option
-
 // namespaces to load, comma to separate. 
 func WithNamespace(name string) Option
 
@@ -101,4 +98,4 @@ config := map[string]interface{}{
     }
 }
 _ = config
-```
\ No newline at end of file
+```
diff --git a/contrib/config/apollo/apollo.go b/contrib/config/apollo/apollo.go
index 1e496f81..0d3b975e 100644
--- a/contrib/config/apollo/apollo.go
+++ b/contrib/config/apollo/apollo.go
@@ -1,7 +1,6 @@
 package apollo
 
 import (
-	"fmt"
 	"strings"
 
 	"github.com/go-kratos/kratos/v2/config"
@@ -28,8 +27,6 @@ type options struct {
 	namespace      string
 	isBackupConfig bool
 	backupPath     string
-
-	logger log.Logger
 }
 
 // WithAppID with apollo config app id
@@ -88,19 +85,8 @@ func WithBackupPath(backupPath string) Option {
 	}
 }
 
-// WithLogger use custom logger to replace default logger.
-func WithLogger(logger log.Logger) Option {
-	return func(o *options) {
-		if logger != nil {
-			o.logger = logger
-		}
-	}
-}
-
 func NewSource(opts ...Option) config.Source {
-	op := options{
-		logger: log.GetLogger(),
-	}
+	op := options{}
 	for _, o := range opts {
 		o(&op)
 	}
@@ -167,10 +153,7 @@ func resolve(key string, value interface{}, target map[string]interface{}) {
 		// current exists, then check existing value type, if it's not map
 		// that means duplicate keys, and at least one is not map instance.
 		if cursor, ok = v.(map[string]interface{}); !ok {
-			_ = log.GetLogger().Log(log.LevelWarn,
-				"msg",
-				fmt.Sprintf("duplicate key: %v\n", strings.Join(keys[:i+1], ".")),
-			)
+			log.Warnf("duplicate key: %v\n", strings.Join(keys[:i+1], "."))
 			break
 		}
 	}
@@ -202,10 +185,7 @@ func (e *apollo) load() []*config.KeyValue {
 		codec := encoding.GetCodec(f)
 		val, err := codec.Marshal(next)
 		if err != nil {
-			_ = e.opt.logger.Log(log.LevelWarn,
-				"msg",
-				fmt.Sprintf("apollo could not handle namespace %s: %v", ns, err),
-			)
+			log.Warnf("apollo could not handle namespace %s: %v", ns, err)
 			continue
 		}
 
@@ -224,7 +204,7 @@ func (e *apollo) Load() (kv []*config.KeyValue, err error) {
 }
 
 func (e *apollo) Watch() (config.Watcher, error) {
-	w, err := newWatcher(e, e.opt.logger)
+	w, err := newWatcher(e)
 	if err != nil {
 		return nil, err
 	}
diff --git a/contrib/config/apollo/watcher.go b/contrib/config/apollo/watcher.go
index 2cda69ef..cd6a4178 100644
--- a/contrib/config/apollo/watcher.go
+++ b/contrib/config/apollo/watcher.go
@@ -2,7 +2,6 @@ package apollo
 
 import (
 	"context"
-	"fmt"
 
 	"github.com/go-kratos/kratos/v2/config"
 	"github.com/go-kratos/kratos/v2/encoding"
@@ -17,8 +16,7 @@ type watcher struct {
 }
 
 type customChangeListener struct {
-	in     chan<- []*config.KeyValue
-	logger log.Logger
+	in chan<- []*config.KeyValue
 }
 
 func (c *customChangeListener) onChange(namespace string, changes map[string]*storage.ConfigChange) []*config.KeyValue {
@@ -33,10 +31,7 @@ func (c *customChangeListener) onChange(namespace string, changes map[string]*st
 	codec := encoding.GetCodec(f)
 	val, err := codec.Marshal(next)
 	if err != nil {
-		_ = c.logger.Log(log.LevelWarn,
-			"msg",
-			fmt.Sprintf("apollo could not handle namespace %s: %v", namespace, err),
-		)
+		log.Warnf("apollo could not handle namespace %s: %v", namespace, err)
 		return nil
 	}
 	kv = append(kv, &config.KeyValue{
@@ -59,15 +54,10 @@ func (c *customChangeListener) OnChange(changeEvent *storage.ChangeEvent) {
 
 func (c *customChangeListener) OnNewestChange(changeEvent *storage.FullChangeEvent) {}
 
-func newWatcher(a *apollo, logger log.Logger) (config.Watcher, error) {
-	if logger == nil {
-		logger = log.GetLogger()
-	}
-
+func newWatcher(a *apollo) (config.Watcher, error) {
 	changeCh := make(chan []*config.KeyValue)
-	listener := &customChangeListener{in: changeCh, logger: logger}
+	listener := &customChangeListener{in: changeCh}
 	a.client.AddChangeListener(listener)
-
 	return &watcher{
 		out: changeCh,
 		cancelFn: func() {
diff --git a/contrib/config/kubernetes/go.mod b/contrib/config/kubernetes/go.mod
index c2256911..b017fb25 100644
--- a/contrib/config/kubernetes/go.mod
+++ b/contrib/config/kubernetes/go.mod
@@ -4,8 +4,8 @@ go 1.16
 
 require (
 	github.com/go-kratos/kratos/v2 v2.3.0
-	k8s.io/api v0.24.0
-	k8s.io/apimachinery v0.24.0
+	k8s.io/api v0.24.1
+	k8s.io/apimachinery v0.24.1
 	k8s.io/client-go v0.24.0
 )
 
diff --git a/contrib/config/kubernetes/go.sum b/contrib/config/kubernetes/go.sum
index e9ce0c47..870c62ca 100644
--- a/contrib/config/kubernetes/go.sum
+++ b/contrib/config/kubernetes/go.sum
@@ -652,10 +652,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-k8s.io/api v0.24.0 h1:J0hann2hfxWr1hinZIDefw7Q96wmCBx6SSB8IY0MdDg=
 k8s.io/api v0.24.0/go.mod h1:5Jl90IUrJHUJYEMANRURMiVvJ0g7Ax7r3R1bqO8zx8I=
-k8s.io/apimachinery v0.24.0 h1:ydFCyC/DjCvFCHK5OPMKBlxayQytB8pxy8YQInd5UyQ=
+k8s.io/api v0.24.1 h1:BjCMRDcyEYz03joa3K1+rbshwh1Ay6oB53+iUx2H8UY=
+k8s.io/api v0.24.1/go.mod h1:JhoOvNiLXKTPQ60zh2g0ewpA+bnEYf5q44Flhquh4vQ=
 k8s.io/apimachinery v0.24.0/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
+k8s.io/apimachinery v0.24.1 h1:ShD4aDxTQKN5zNf8K1RQ2u98ELLdIW7jEnlO9uAMX/I=
+k8s.io/apimachinery v0.24.1/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
 k8s.io/client-go v0.24.0 h1:lbE4aB1gTHvYFSwm6eD3OF14NhFDKCejlnsGYlSJe5U=
 k8s.io/client-go v0.24.0/go.mod h1:VFPQET+cAFpYxh6Bq6f4xyMY80G6jKKktU6G0m00VDw=
 k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
diff --git a/contrib/log/aliyun/go.mod b/contrib/log/aliyun/go.mod
index 9e9c4323..bdecf49c 100644
--- a/contrib/log/aliyun/go.mod
+++ b/contrib/log/aliyun/go.mod
@@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/log/aliyun/v2
 go 1.16
 
 require (
-	github.com/aliyun/aliyun-log-go-sdk v0.1.35
+	github.com/aliyun/aliyun-log-go-sdk v0.1.36
 	github.com/go-kratos/kratos/v2 v2.3.0
 	google.golang.org/protobuf v1.28.0
 )
diff --git a/contrib/log/aliyun/go.sum b/contrib/log/aliyun/go.sum
index ae93aa14..2ad1b613 100644
--- a/contrib/log/aliyun/go.sum
+++ b/contrib/log/aliyun/go.sum
@@ -12,8 +12,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
 github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
-github.com/aliyun/aliyun-log-go-sdk v0.1.35 h1:TIQaD5gwJtsjFVrK0Y2qskqge+DgfTEIjwT3RVcZm9M=
-github.com/aliyun/aliyun-log-go-sdk v0.1.35/go.mod h1:1QQ59pEJiVVXqKgbHcU6FWIgxT5RKBt+CT8AiQ2bEts=
+github.com/aliyun/aliyun-log-go-sdk v0.1.36 h1:ZWhKl1tBOvRn3/sIrFy8gMX+Hfq2u8mee1DeU96jqjc=
+github.com/aliyun/aliyun-log-go-sdk v0.1.36/go.mod h1:1QQ59pEJiVVXqKgbHcU6FWIgxT5RKBt+CT8AiQ2bEts=
 github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
 github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
 github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
diff --git a/contrib/registry/discovery/README.md b/contrib/registry/discovery/README.md
index b220b629..46c46e2d 100644
--- a/contrib/registry/discovery/README.md
+++ b/contrib/registry/discovery/README.md
@@ -14,9 +14,6 @@ import (
 )
 
 func main() {
-	logger := log.NewStdLogger(os.Stdout)
-	logger = log.With(logger, "service", "example.registry.discovery")
-	
 	// initialize a registry
 	r := discovery.New(&discovery.Config{
 		Nodes:  []string{"0.0.0.0:7171"},
@@ -24,7 +21,7 @@ func main() {
 		Region: "sh1",
 		Zone:   "zone1",
 		Host:   "hostname",
-	}, logger)
+	})
 
 	// construct srv instance
 	// ...
diff --git a/contrib/registry/discovery/discovery.go b/contrib/registry/discovery/discovery.go
index 9c85c0ab..f6df56dc 100644
--- a/contrib/registry/discovery/discovery.go
+++ b/contrib/registry/discovery/discovery.go
@@ -5,16 +5,14 @@ import (
 	"fmt"
 	"math/rand"
 	"net/url"
-	"os"
 	"strconv"
 	"sync"
 	"sync/atomic"
 	"time"
 
+	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-resty/resty/v2"
 	"github.com/pkg/errors"
-
-	"github.com/go-kratos/kratos/v2/log"
 )
 
 type Discovery struct {
@@ -32,8 +30,6 @@ type Discovery struct {
 	registry    map[string]struct{}
 	lastHost    string
 	cancelPolls context.CancelFunc
-
-	logger log.Logger
 }
 
 type appInfo struct {
@@ -44,15 +40,7 @@ type appInfo struct {
 
 // New construct a Discovery instance which implements registry.Registrar,
 // registry.Discovery and registry.Watcher.
-func New(c *Config, logger log.Logger) *Discovery {
-	if logger == nil {
-		logger = log.NewStdLogger(os.Stdout)
-		logger = log.With(logger,
-			"registry.pluginName", "Discovery",
-			"ts", log.DefaultTimestamp,
-			"caller", log.DefaultCaller,
-		)
-	}
+func New(c *Config) *Discovery {
 	if c == nil {
 		c = new(Config)
 	}
@@ -66,7 +54,6 @@ func New(c *Config, logger log.Logger) *Discovery {
 		cancelFunc: cancel,
 		apps:       map[string]*appInfo{},
 		registry:   map[string]struct{}{},
-		logger:     logger,
 	}
 
 	d.httpClient = resty.New().
@@ -94,10 +81,6 @@ func (d *Discovery) Close() error {
 	return nil
 }
 
-func (d *Discovery) Logger() *log.Helper {
-	return log.NewHelper(d.logger)
-}
-
 // selfProc start a goroutine to refresh Discovery self registration information.
 func (d *Discovery) selfProc(resolver *Resolve, event <-chan struct{}) {
 	for {
@@ -178,7 +161,7 @@ func (d *Discovery) resolveBuild(appID string) *Resolve {
 		}
 	}
 
-	d.Logger().Debugf("Discovery: AddWatch(%s) already watch(%v)", appID, ok)
+	log.Debugf("Discovery: AddWatch(%s) already watch(%v)", appID, ok)
 	d.once.Do(func() {
 		go d.serverProc()
 	})
@@ -186,7 +169,7 @@ func (d *Discovery) resolveBuild(appID string) *Resolve {
 }
 
 func (d *Discovery) serverProc() {
-	defer d.Logger().Debug("Discovery serverProc quit")
+	defer log.Debug("Discovery serverProc quit")
 
 	var (
 		retry  int
@@ -242,8 +225,6 @@ func (d *Discovery) switchNode() {
 
 // renew an instance with Discovery
 func (d *Discovery) renew(ctx context.Context, ins *discoveryInstance) (err error) {
-	// d.Logger().Debug("Discovery:renew renew calling")
-
 	d.mutex.RLock()
 	c := d.config
 	d.mutex.RUnlock()
@@ -262,7 +243,7 @@ func (d *Discovery) renew(ctx context.Context, ins *discoveryInstance) (err erro
 		SetResult(&res).
 		Post(uri); err != nil {
 		d.switchNode()
-		d.Logger().Errorf("Discovery: renew client.Get(%v) env(%s) appid(%s) hostname(%s) error(%v)",
+		log.Errorf("Discovery: renew client.Get(%v) env(%s) appid(%s) hostname(%s) error(%v)",
 			uri, c.Env, ins.AppID, c.Host, err)
 		return
 	}
@@ -276,7 +257,7 @@ func (d *Discovery) renew(ctx context.Context, ins *discoveryInstance) (err erro
 			return
 		}
 
-		d.Logger().Errorf(
+		log.Errorf(
 			"Discovery: renew client.Get(%v) env(%s) appid(%s) hostname(%s) code(%v)",
 			uri, c.Env, ins.AppID, c.Host, res.Code,
 		)
@@ -304,7 +285,7 @@ func (d *Discovery) cancel(ins *discoveryInstance) (err error) {
 		SetResult(&res).
 		Post(uri); err != nil {
 		d.switchNode()
-		d.Logger().Errorf("Discovery cancel client.Get(%v) env(%s) appid(%s) hostname(%s) error(%v)",
+		log.Errorf("Discovery cancel client.Get(%v) env(%s) appid(%s) hostname(%s) error(%v)",
 			uri, config.Env, ins.AppID, config.Host, err)
 		return
 	}
@@ -315,7 +296,7 @@ func (d *Discovery) cancel(ins *discoveryInstance) (err error) {
 			return nil
 		}
 
-		d.Logger().Warnf("Discovery cancel client.Get(%v)  env(%s) appid(%s) hostname(%s) code(%v)",
+		log.Warnf("Discovery cancel client.Get(%v)  env(%s) appid(%s) hostname(%s) code(%v)",
 			uri, config.Env, ins.AppID, config.Host, res.Code)
 		err = fmt.Errorf("ErrorCode: %d", res.Code)
 		return
@@ -407,13 +388,13 @@ func (d *Discovery) polls(ctx context.Context) (apps map[string]*disInstancesInf
 		SetQueryParamsFromValues(p).
 		SetResult(res).Get(uri); err != nil {
 		d.switchNode()
-		d.Logger().Errorf("Discovery: client.Get(%s) error(%+v)", reqURI, err)
+		log.Errorf("Discovery: client.Get(%s) error(%+v)", reqURI, err)
 		return nil, err
 	}
 
 	if res.Code != _codeOK {
 		if res.Code != _codeNotModified {
-			d.Logger().Errorf("Discovery: client.Get(%s) get error code(%d)", reqURI, res.Code)
+			log.Errorf("Discovery: client.Get(%s) get error code(%d)", reqURI, res.Code)
 		}
 		err = fmt.Errorf("discovery.polls failed ErrCode: %d", res.Code)
 		return
@@ -422,12 +403,12 @@ func (d *Discovery) polls(ctx context.Context) (apps map[string]*disInstancesInf
 	for _, app := range res.Data {
 		if app.LastTs == 0 {
 			err = ErrServerError
-			d.Logger().Errorf("Discovery: client.Get(%s) latest_timestamp is 0, instances:(%+v)", reqURI, res.Data)
+			log.Errorf("Discovery: client.Get(%s) latest_timestamp is 0, instances:(%+v)", reqURI, res.Data)
 			return
 		}
 	}
 
-	d.Logger().Debugf("Discovery: successfully polls(%s) instances (%+v)", reqURI, res.Data)
+	log.Debugf("Discovery: successfully polls(%s) instances (%+v)", reqURI, res.Data)
 	apps = res.Data
 	return
 }
diff --git a/contrib/registry/discovery/impl_registrar.go b/contrib/registry/discovery/impl_registrar.go
index f044d8b6..c5590f57 100644
--- a/contrib/registry/discovery/impl_registrar.go
+++ b/contrib/registry/discovery/impl_registrar.go
@@ -9,6 +9,7 @@ import (
 
 	"github.com/pkg/errors"
 
+	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/registry"
 )
 
@@ -43,7 +44,7 @@ func (d *Discovery) Register(ctx context.Context, service *registry.ServiceInsta
 
 	// renew the current register_service
 	go func() {
-		defer d.Logger().Warn("Discovery:register_service goroutine quit")
+		defer log.Warn("Discovery:register_service goroutine quit")
 		ticker := time.NewTicker(_registerGap)
 		defer ticker.Stop()
 		for {
@@ -70,7 +71,7 @@ func (d *Discovery) register(ctx context.Context, ins *discoveryInstance) (err e
 	var metadata []byte
 	if ins.Metadata != nil {
 		if metadata, err = json.Marshal(ins.Metadata); err != nil {
-			d.Logger().Errorf(
+			log.Errorf(
 				"Discovery:register instance Marshal metadata(%v) failed!error(%v)", ins.Metadata, err,
 			)
 		}
@@ -102,18 +103,18 @@ func (d *Discovery) register(ctx context.Context, ins *discoveryInstance) (err e
 		SetResult(&res).
 		Post(uri); err != nil {
 		d.switchNode()
-		d.Logger().Errorf("Discovery: register client.Get(%s)  zone(%s) env(%s) appid(%s) addrs(%v) error(%v)",
+		log.Errorf("Discovery: register client.Get(%s)  zone(%s) env(%s) appid(%s) addrs(%v) error(%v)",
 			uri+"?"+p.Encode(), c.Zone, c.Env, ins.AppID, ins.Addrs, err)
 		return
 	}
 
 	if res.Code != 0 {
 		err = fmt.Errorf("ErrorCode: %d", res.Code)
-		d.Logger().Errorf("Discovery: register client.Get(%v)  env(%s) appid(%s) addrs(%v) code(%v)",
+		log.Errorf("Discovery: register client.Get(%v)  env(%s) appid(%s) addrs(%v) code(%v)",
 			uri, c.Env, ins.AppID, ins.Addrs, res.Code)
 	}
 
-	d.Logger().Infof(
+	log.Infof(
 		"Discovery: register client.Get(%v) env(%s) appid(%s) addrs(%s) success\n",
 		uri, c.Env, ins.AppID, ins.Addrs,
 	)
diff --git a/contrib/registry/kubernetes/go.mod b/contrib/registry/kubernetes/go.mod
index 40396de9..a9641191 100644
--- a/contrib/registry/kubernetes/go.mod
+++ b/contrib/registry/kubernetes/go.mod
@@ -5,8 +5,8 @@ go 1.16
 require (
 	github.com/go-kratos/kratos/v2 v2.3.0
 	github.com/json-iterator/go v1.1.12
-	k8s.io/api v0.24.0
-	k8s.io/apimachinery v0.24.0
+	k8s.io/api v0.24.1
+	k8s.io/apimachinery v0.24.1
 	k8s.io/client-go v0.24.0
 )
 
diff --git a/contrib/registry/kubernetes/go.sum b/contrib/registry/kubernetes/go.sum
index b2fe017b..e314e188 100644
--- a/contrib/registry/kubernetes/go.sum
+++ b/contrib/registry/kubernetes/go.sum
@@ -652,10 +652,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-k8s.io/api v0.24.0 h1:J0hann2hfxWr1hinZIDefw7Q96wmCBx6SSB8IY0MdDg=
 k8s.io/api v0.24.0/go.mod h1:5Jl90IUrJHUJYEMANRURMiVvJ0g7Ax7r3R1bqO8zx8I=
-k8s.io/apimachinery v0.24.0 h1:ydFCyC/DjCvFCHK5OPMKBlxayQytB8pxy8YQInd5UyQ=
+k8s.io/api v0.24.1 h1:BjCMRDcyEYz03joa3K1+rbshwh1Ay6oB53+iUx2H8UY=
+k8s.io/api v0.24.1/go.mod h1:JhoOvNiLXKTPQ60zh2g0ewpA+bnEYf5q44Flhquh4vQ=
 k8s.io/apimachinery v0.24.0/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
+k8s.io/apimachinery v0.24.1 h1:ShD4aDxTQKN5zNf8K1RQ2u98ELLdIW7jEnlO9uAMX/I=
+k8s.io/apimachinery v0.24.1/go.mod h1:82Bi4sCzVBdpYjyI4jY6aHX+YCUchUIrZrXKedjd2UM=
 k8s.io/client-go v0.24.0 h1:lbE4aB1gTHvYFSwm6eD3OF14NhFDKCejlnsGYlSJe5U=
 k8s.io/client-go v0.24.0/go.mod h1:VFPQET+cAFpYxh6Bq6f4xyMY80G6jKKktU6G0m00VDw=
 k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
diff --git a/log/global.go b/log/global.go
index a44d0b76..6dbc722a 100644
--- a/log/global.go
+++ b/log/global.go
@@ -2,6 +2,8 @@ package log
 
 import (
 	"context"
+	"fmt"
+	"os"
 	"sync"
 )
 
@@ -13,7 +15,6 @@ var global = &loggerAppliance{}
 type loggerAppliance struct {
 	lock sync.Mutex
 	Logger
-	helper *Helper
 }
 
 func init() {
@@ -24,7 +25,6 @@ func (a *loggerAppliance) SetLogger(in Logger) {
 	a.lock.Lock()
 	defer a.lock.Unlock()
 	a.Logger = in
-	a.helper = NewHelper(a.Logger)
 }
 
 func (a *loggerAppliance) GetLogger() Logger {
@@ -44,84 +44,88 @@ func GetLogger() Logger {
 
 // Log Print log by level and keyvals.
 func Log(level Level, keyvals ...interface{}) {
-	global.helper.Log(level, keyvals...)
+	_ = global.Log(level, keyvals...)
 }
 
+// Context with context logger.
 func Context(ctx context.Context) *Helper {
-	return global.helper.WithContext(ctx)
+	return NewHelper(WithContext(ctx, global))
 }
 
 // Debug logs a message at debug level.
 func Debug(a ...interface{}) {
-	global.helper.Debug(a...)
+	_ = global.Log(LevelDebug, DefaultMessageKey, fmt.Sprint(a...))
 }
 
 // Debugf logs a message at debug level.
 func Debugf(format string, a ...interface{}) {
-	global.helper.Debugf(format, a...)
+	_ = global.Log(LevelDebug, DefaultMessageKey, fmt.Sprintf(format, a...))
 }
 
 // Debugw logs a message at debug level.
 func Debugw(keyvals ...interface{}) {
-	global.helper.Debugw(keyvals...)
+	_ = global.Log(LevelDebug, keyvals...)
 }
 
 // Info logs a message at info level.
 func Info(a ...interface{}) {
-	global.helper.Info(a...)
+	_ = global.Log(LevelInfo, DefaultMessageKey, fmt.Sprint(a...))
 }
 
 // Infof logs a message at info level.
 func Infof(format string, a ...interface{}) {
-	global.helper.Infof(format, a...)
+	_ = global.Log(LevelInfo, DefaultMessageKey, fmt.Sprintf(format, a...))
 }
 
 // Infow logs a message at info level.
 func Infow(keyvals ...interface{}) {
-	global.helper.Infow(keyvals...)
+	_ = global.Log(LevelInfo, keyvals...)
 }
 
 // Warn logs a message at warn level.
 func Warn(a ...interface{}) {
-	global.helper.Warn(a...)
+	_ = global.Log(LevelWarn, DefaultMessageKey, fmt.Sprint(a...))
 }
 
 // Warnf logs a message at warnf level.
 func Warnf(format string, a ...interface{}) {
-	global.helper.Warnf(format, a...)
+	_ = global.Log(LevelWarn, DefaultMessageKey, fmt.Sprintf(format, a...))
 }
 
 // Warnw logs a message at warnf level.
 func Warnw(keyvals ...interface{}) {
-	global.helper.Warnw(keyvals...)
+	_ = global.Log(LevelWarn, keyvals...)
 }
 
 // Error logs a message at error level.
 func Error(a ...interface{}) {
-	global.helper.Error(a...)
+	_ = global.Log(LevelError, DefaultMessageKey, fmt.Sprint(a...))
 }
 
 // Errorf logs a message at error level.
 func Errorf(format string, a ...interface{}) {
-	global.helper.Errorf(format, a...)
+	_ = global.Log(LevelError, DefaultMessageKey, fmt.Sprintf(format, a...))
 }
 
 // Errorw logs a message at error level.
 func Errorw(keyvals ...interface{}) {
-	global.helper.Errorw(keyvals...)
+	_ = global.Log(LevelError, keyvals...)
 }
 
 // Fatal logs a message at fatal level.
 func Fatal(a ...interface{}) {
-	global.helper.Fatal(a...)
+	_ = global.Log(LevelFatal, DefaultMessageKey, fmt.Sprint(a...))
+	os.Exit(1)
 }
 
 // Fatalf logs a message at fatal level.
 func Fatalf(format string, a ...interface{}) {
-	global.helper.Fatalf(format, a...)
+	_ = global.Log(LevelFatal, DefaultMessageKey, fmt.Sprintf(format, a...))
+	os.Exit(1)
 }
 
 // Fatalw logs a message at fatal level.
 func Fatalw(keyvals ...interface{}) {
-	global.helper.Fatalw(keyvals...)
+	_ = global.Log(LevelFatal, keyvals...)
+	os.Exit(1)
 }
diff --git a/log/value.go b/log/value.go
index 8154ae93..36782f0d 100644
--- a/log/value.go
+++ b/log/value.go
@@ -40,6 +40,10 @@ func Caller(depth int) Valuer {
 			d++
 			_, file, line, _ = runtime.Caller(d)
 		}
+		if strings.LastIndex(file, "/log/global.go") > 0 {
+			d++
+			_, file, line, _ = runtime.Caller(d)
+		}
 		idx := strings.LastIndexByte(file, '/')
 		return file[idx+1:] + ":" + strconv.Itoa(line)
 	}
diff --git a/middleware/recovery/recovery.go b/middleware/recovery/recovery.go
index 298d7531..dfa7cb7f 100644
--- a/middleware/recovery/recovery.go
+++ b/middleware/recovery/recovery.go
@@ -20,7 +20,6 @@ type Option func(*options)
 
 type options struct {
 	handler HandlerFunc
-	logger  log.Logger
 }
 
 // WithHandler with recovery handler.
@@ -31,16 +30,14 @@ func WithHandler(h HandlerFunc) Option {
 }
 
 // WithLogger with recovery logger.
+// Deprecated: use global logger instead.
 func WithLogger(logger log.Logger) Option {
-	return func(o *options) {
-		o.logger = logger
-	}
+	return func(o *options) {}
 }
 
 // Recovery is a server middleware that recovers from any panics.
 func Recovery(opts ...Option) middleware.Middleware {
 	op := options{
-		logger: log.GetLogger(),
 		handler: func(ctx context.Context, req, err interface{}) error {
 			return ErrUnknownRequest
 		},
@@ -48,7 +45,6 @@ func Recovery(opts ...Option) middleware.Middleware {
 	for _, o := range opts {
 		o(&op)
 	}
-	logger := log.NewHelper(op.logger)
 	return func(handler middleware.Handler) middleware.Handler {
 		return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
 			defer func() {
@@ -56,7 +52,7 @@ func Recovery(opts ...Option) middleware.Middleware {
 					buf := make([]byte, 64<<10) //nolint:gomnd
 					n := runtime.Stack(buf, false)
 					buf = buf[:n]
-					logger.WithContext(ctx).Errorf("%v: %+v\n%s\n", rerr, req, buf)
+					log.Context(ctx).Errorf("%v: %+v\n%s\n", rerr, req, buf)
 
 					err = op.handler(ctx, req, rerr)
 				}
diff --git a/options.go b/options.go
index d18d75da..8f9e9a55 100644
--- a/options.go
+++ b/options.go
@@ -25,7 +25,7 @@ type options struct {
 	ctx  context.Context
 	sigs []os.Signal
 
-	logger           *log.Helper
+	logger           log.Logger
 	registrar        registry.Registrar
 	registrarTimeout time.Duration
 	stopTimeout      time.Duration
@@ -64,9 +64,7 @@ func Context(ctx context.Context) Option {
 
 // Logger with service logger.
 func Logger(logger log.Logger) Option {
-	return func(o *options) {
-		o.logger = log.NewHelper(logger)
-	}
+	return func(o *options) { o.logger = logger }
 }
 
 // Server with transport servers.
diff --git a/transport/grpc/client.go b/transport/grpc/client.go
index 538e4343..a5174b73 100644
--- a/transport/grpc/client.go
+++ b/transport/grpc/client.go
@@ -90,10 +90,9 @@ func WithFilter(filters ...selector.Filter) ClientOption {
 }
 
 // WithLogger with logger
+// Deprecated: use global logger instead.
 func WithLogger(log log.Logger) ClientOption {
-	return func(o *clientOptions) {
-		o.logger = log
-	}
+	return func(o *clientOptions) {}
 }
 
 // clientOptions is gRPC Client
@@ -107,7 +106,6 @@ type clientOptions struct {
 	grpcOpts     []grpc.DialOption
 	balancerName string
 	filters      []selector.Filter
-	logger       log.Logger
 }
 
 // Dial returns a GRPC connection.
@@ -124,7 +122,6 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
 	options := clientOptions{
 		timeout:      2000 * time.Millisecond,
 		balancerName: wrr.Name,
-		logger:       log.GetLogger(),
 	}
 	for _, o := range opts {
 		o(&options)
@@ -145,7 +142,6 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
 				discovery.NewBuilder(
 					options.discovery,
 					discovery.WithInsecure(insecure),
-					discovery.WithLogger(options.logger),
 				)))
 	}
 	if insecure {
diff --git a/transport/grpc/resolver/discovery/builder.go b/transport/grpc/resolver/discovery/builder.go
index 5c98e519..7ce77717 100644
--- a/transport/grpc/resolver/discovery/builder.go
+++ b/transport/grpc/resolver/discovery/builder.go
@@ -6,7 +6,6 @@ import (
 	"strings"
 	"time"
 
-	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/registry"
 
 	"google.golang.org/grpc/resolver"
@@ -17,13 +16,6 @@ const name = "discovery"
 // Option is builder option.
 type Option func(o *builder)
 
-// WithLogger with builder logger.
-func WithLogger(logger log.Logger) Option {
-	return func(b *builder) {
-		b.logger = logger
-	}
-}
-
 // WithTimeout with timeout option.
 func WithTimeout(timeout time.Duration) Option {
 	return func(b *builder) {
@@ -47,7 +39,6 @@ func DisableDebugLog() Option {
 
 type builder struct {
 	discoverer       registry.Discovery
-	logger           log.Logger
 	timeout          time.Duration
 	insecure         bool
 	debugLogDisabled bool
@@ -57,7 +48,6 @@ type builder struct {
 func NewBuilder(d registry.Discovery, opts ...Option) resolver.Builder {
 	b := &builder{
 		discoverer:       d,
-		logger:           log.GetLogger(),
 		timeout:          time.Second * 10,
 		insecure:         false,
 		debugLogDisabled: false,
@@ -93,7 +83,6 @@ func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, opts res
 		cc:               cc,
 		ctx:              ctx,
 		cancel:           cancel,
-		log:              log.NewHelper(b.logger),
 		insecure:         b.insecure,
 		debugLogDisabled: b.debugLogDisabled,
 	}
diff --git a/transport/grpc/resolver/discovery/resolver.go b/transport/grpc/resolver/discovery/resolver.go
index 79d5da1c..770fa801 100644
--- a/transport/grpc/resolver/discovery/resolver.go
+++ b/transport/grpc/resolver/discovery/resolver.go
@@ -15,9 +15,8 @@ import (
 )
 
 type discoveryResolver struct {
-	w   registry.Watcher
-	cc  resolver.ClientConn
-	log *log.Helper
+	w  registry.Watcher
+	cc resolver.ClientConn
 
 	ctx    context.Context
 	cancel context.CancelFunc
@@ -38,7 +37,7 @@ func (r *discoveryResolver) watch() {
 			if errors.Is(err, context.Canceled) {
 				return
 			}
-			r.log.Errorf("[resolver] Failed to watch discovery endpoint: %v", err)
+			log.Errorf("[resolver] Failed to watch discovery endpoint: %v", err)
 			time.Sleep(time.Second)
 			continue
 		}
@@ -52,7 +51,7 @@ func (r *discoveryResolver) update(ins []*registry.ServiceInstance) {
 	for _, in := range ins {
 		endpoint, err := endpoint.ParseEndpoint(in.Endpoints, "grpc", !r.insecure)
 		if err != nil {
-			r.log.Errorf("[resolver] Failed to parse discovery endpoint: %v", err)
+			log.Errorf("[resolver] Failed to parse discovery endpoint: %v", err)
 			continue
 		}
 		if endpoint == "" {
@@ -72,17 +71,17 @@ func (r *discoveryResolver) update(ins []*registry.ServiceInstance) {
 		addrs = append(addrs, addr)
 	}
 	if len(addrs) == 0 {
-		r.log.Warnf("[resolver] Zero endpoint found,refused to write, instances: %v", ins)
+		log.Warnf("[resolver] Zero endpoint found,refused to write, instances: %v", ins)
 		return
 	}
 	err := r.cc.UpdateState(resolver.State{Addresses: addrs})
 	if err != nil {
-		r.log.Errorf("[resolver] failed to update state: %s", err)
+		log.Errorf("[resolver] failed to update state: %s", err)
 	}
 
 	if !r.debugLogDisabled {
 		b, _ := json.Marshal(ins)
-		r.log.Infof("[resolver] update instances: %s", b)
+		log.Infof("[resolver] update instances: %s", b)
 	}
 }
 
@@ -90,7 +89,7 @@ func (r *discoveryResolver) Close() {
 	r.cancel()
 	err := r.w.Stop()
 	if err != nil {
-		r.log.Errorf("[resolver] failed to watch top: %s", err)
+		log.Errorf("[resolver] failed to watch top: %s", err)
 	}
 }
 
diff --git a/transport/grpc/server.go b/transport/grpc/server.go
index 1ca63551..8ec76884 100644
--- a/transport/grpc/server.go
+++ b/transport/grpc/server.go
@@ -54,10 +54,9 @@ func Timeout(timeout time.Duration) ServerOption {
 }
 
 // Logger with server logger.
+// Deprecated: use global logger instead.
 func Logger(logger log.Logger) ServerOption {
-	return func(s *Server) {
-		s.log = log.NewHelper(logger)
-	}
+	return func(s *Server) {}
 }
 
 // Middleware with server middleware.
@@ -113,7 +112,6 @@ type Server struct {
 	address    string
 	endpoint   *url.URL
 	timeout    time.Duration
-	log        *log.Helper
 	middleware []middleware.Middleware
 	unaryInts  []grpc.UnaryServerInterceptor
 	streamInts []grpc.StreamServerInterceptor
@@ -130,7 +128,6 @@ func NewServer(opts ...ServerOption) *Server {
 		address: ":0",
 		timeout: 1 * time.Second,
 		health:  health.NewServer(),
-		log:     log.NewHelper(log.GetLogger()),
 	}
 	for _, o := range opts {
 		o(srv)
@@ -184,7 +181,7 @@ func (s *Server) Start(ctx context.Context) error {
 		return s.err
 	}
 	s.baseCtx = ctx
-	s.log.Infof("[gRPC] server listening on: %s", s.lis.Addr().String())
+	log.Infof("[gRPC] server listening on: %s", s.lis.Addr().String())
 	s.health.Resume()
 	return s.Serve(s.lis)
 }
@@ -193,7 +190,7 @@ func (s *Server) Start(ctx context.Context) error {
 func (s *Server) Stop(ctx context.Context) error {
 	s.health.Shutdown()
 	s.GracefulStop()
-	s.log.Info("[gRPC] server stopping")
+	log.Info("[gRPC] server stopping")
 	return nil
 }
 
diff --git a/transport/http/resolver.go b/transport/http/resolver.go
index 6bb1c3ff..1a4ba81c 100644
--- a/transport/http/resolver.go
+++ b/transport/http/resolver.go
@@ -44,7 +44,6 @@ type resolver struct {
 
 	target  *Target
 	watcher registry.Watcher
-	logger  *log.Helper
 
 	insecure bool
 }
@@ -57,7 +56,6 @@ func newResolver(ctx context.Context, discovery registry.Discovery, target *Targ
 	r := &resolver{
 		target:     target,
 		watcher:    watcher,
-		logger:     log.NewHelper(log.GetLogger()),
 		rebalancer: rebalancer,
 		insecure:   insecure,
 	}
@@ -81,15 +79,15 @@ func newResolver(ctx context.Context, discovery registry.Discovery, target *Targ
 			if err != nil {
 				stopErr := watcher.Stop()
 				if stopErr != nil {
-					r.logger.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
+					log.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
 				}
 				return nil, err
 			}
 		case <-ctx.Done():
-			r.logger.Errorf("http client watch service %v reaching context deadline!", target)
+			log.Errorf("http client watch service %v reaching context deadline!", target)
 			stopErr := watcher.Stop()
 			if stopErr != nil {
-				r.logger.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
+				log.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
 			}
 			return nil, ctx.Err()
 		}
@@ -101,7 +99,7 @@ func newResolver(ctx context.Context, discovery registry.Discovery, target *Targ
 				if errors.Is(err, context.Canceled) {
 					return
 				}
-				r.logger.Errorf("http client watch service %v got unexpected error:=%v", target, err)
+				log.Errorf("http client watch service %v got unexpected error:=%v", target, err)
 				time.Sleep(time.Second)
 				continue
 			}
@@ -116,7 +114,7 @@ func (r *resolver) update(services []*registry.ServiceInstance) bool {
 	for _, ins := range services {
 		ept, err := endpoint.ParseEndpoint(ins.Endpoints, "http", !r.insecure)
 		if err != nil {
-			r.logger.Errorf("Failed to parse (%v) discovery endpoint: %v error %v", r.target, ins.Endpoints, err)
+			log.Errorf("Failed to parse (%v) discovery endpoint: %v error %v", r.target, ins.Endpoints, err)
 			continue
 		}
 		if ept == "" {
@@ -125,7 +123,7 @@ func (r *resolver) update(services []*registry.ServiceInstance) bool {
 		nodes = append(nodes, selector.NewNode("http", ept, ins))
 	}
 	if len(nodes) == 0 {
-		r.logger.Warnf("[http resolver]Zero endpoint found,refused to write,set: %s ins: %v", r.target.Endpoint, nodes)
+		log.Warnf("[http resolver]Zero endpoint found,refused to write,set: %s ins: %v", r.target.Endpoint, nodes)
 		return false
 	}
 	r.rebalancer.Apply(nodes)
diff --git a/transport/http/server.go b/transport/http/server.go
index c9a0597f..58f3060d 100644
--- a/transport/http/server.go
+++ b/transport/http/server.go
@@ -49,10 +49,9 @@ func Timeout(timeout time.Duration) ServerOption {
 }
 
 // Logger with server logger.
+// Deprecated: use global logger instead.
 func Logger(logger log.Logger) ServerOption {
-	return func(s *Server) {
-		s.log = log.NewHelper(logger)
-	}
+	return func(s *Server) {}
 }
 
 // Middleware with service middleware option.
@@ -130,7 +129,6 @@ type Server struct {
 	ene         EncodeErrorFunc
 	strictSlash bool
 	router      *mux.Router
-	log         *log.Helper
 }
 
 // NewServer creates an HTTP server by options.
@@ -143,7 +141,6 @@ func NewServer(opts ...ServerOption) *Server {
 		enc:         DefaultResponseEncoder,
 		ene:         DefaultErrorEncoder,
 		strictSlash: true,
-		log:         log.NewHelper(log.GetLogger()),
 	}
 	for _, o := range opts {
 		o(srv)
@@ -243,7 +240,7 @@ func (s *Server) Start(ctx context.Context) error {
 	s.BaseContext = func(net.Listener) context.Context {
 		return ctx
 	}
-	s.log.Infof("[HTTP] server listening on: %s", s.lis.Addr().String())
+	log.Infof("[HTTP] server listening on: %s", s.lis.Addr().String())
 	var err error
 	if s.tlsConf != nil {
 		err = s.ServeTLS(s.lis, "", "")
@@ -258,7 +255,7 @@ func (s *Server) Start(ctx context.Context) error {
 
 // Stop stop the HTTP server.
 func (s *Server) Stop(ctx context.Context) error {
-	s.log.Info("[HTTP] server stopping")
+	log.Info("[HTTP] server stopping")
 	return s.Shutdown(ctx)
 }
 


Test patch:
diff --git a/app_test.go b/app_test.go
index 9165ce07..80831b54 100644
--- a/app_test.go
+++ b/app_test.go
@@ -154,7 +154,7 @@ func TestApp_Endpoint(t *testing.T) {
 				endpoint []string
 				metadata map[string]string
 			}{
-				id: "3", version: "v3", name: "kratos-v3", endpoint: []string{},
+				id: "3", version: "v3", name: "kratos-v3", endpoint: nil,
 				metadata: map[string]string{},
 			},
 		},
diff --git a/config/config_test.go b/config/config_test.go
index d08a00d5..5699dec1 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -4,8 +4,6 @@ import (
 	"errors"
 	"reflect"
 	"testing"
-
-	"github.com/go-kratos/kratos/v2/log"
 )
 
 const (
@@ -123,7 +121,6 @@ func TestConfig(t *testing.T) {
 		WithSource(newTestJSONSource(_testJSON)),
 		WithDecoder(defaultDecoder),
 		WithResolver(defaultResolver),
-		WithLogger(log.GetLogger()),
 	)
 	err = c.Close()
 	if err != nil {
@@ -135,12 +132,10 @@ func TestConfig(t *testing.T) {
 		sources:  []Source{jSource},
 		decoder:  defaultDecoder,
 		resolver: defaultResolver,
-		logger:   log.GetLogger(),
 	}
 	cf := &config{}
 	cf.opts = opts
 	cf.reader = newReader(opts)
-	cf.log = log.NewHelper(opts.logger)
 
 	err = cf.Load()
 	if err != nil {
diff --git a/middleware/recovery/recovery_test.go b/middleware/recovery/recovery_test.go
index aa77ab9f..cf4a7fbb 100644
--- a/middleware/recovery/recovery_test.go
+++ b/middleware/recovery/recovery_test.go
@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/go-kratos/kratos/v2/errors"
-	"github.com/go-kratos/kratos/v2/log"
 )
 
 func TestOnce(t *testing.T) {
@@ -19,7 +18,7 @@ func TestOnce(t *testing.T) {
 	next := func(ctx context.Context, req interface{}) (interface{}, error) {
 		panic("panic reason")
 	}
-	_, e := Recovery(WithLogger(log.GetLogger()))(next)(context.Background(), "panic")
+	_, e := Recovery()(next)(context.Background(), "panic")
 	t.Logf("succ and reason is %v", e)
 }
 
diff --git a/options_test.go b/options_test.go
index 953c52f5..4880bd19 100644
--- a/options_test.go
+++ b/options_test.go
@@ -79,7 +79,7 @@ func TestLogger(t *testing.T) {
 	o := &options{}
 	v := xlog.NewStdLogger(log.Writer())
 	Logger(v)(o)
-	if !reflect.DeepEqual(xlog.NewHelper(v), o.logger) {
+	if !reflect.DeepEqual(v, o.logger) {
 		t.Fatalf("o.logger:%v is not equal to xlog.NewHelper(v):%v", o.logger, xlog.NewHelper(v))
 	}
 }
diff --git a/transport/grpc/client_test.go b/transport/grpc/client_test.go
index 1443b9b8..d2540a7d 100644
--- a/transport/grpc/client_test.go
+++ b/transport/grpc/client_test.go
@@ -7,7 +7,6 @@ import (
 	"testing"
 	"time"
 
-	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/middleware"
 	"github.com/go-kratos/kratos/v2/registry"
 	"google.golang.org/grpc"
@@ -70,15 +69,6 @@ func TestWithTLSConfig(t *testing.T) {
 	}
 }
 
-func TestWithLogger(t *testing.T) {
-	o := &clientOptions{}
-	v := log.DefaultLogger
-	WithLogger(v)(o)
-	if !reflect.DeepEqual(v, o.logger) {
-		t.Errorf("expect %v but got %v", v, o.logger)
-	}
-}
-
 func EmptyMiddleware() middleware.Middleware {
 	return func(handler middleware.Handler) middleware.Handler {
 		return func(ctx context.Context, req interface{}) (reply interface{}, err error) {
@@ -145,7 +135,6 @@ func TestDialConn(t *testing.T) {
 		true,
 		WithDiscovery(&mockRegistry{}),
 		WithTimeout(10*time.Second),
-		WithLogger(log.DefaultLogger),
 		WithEndpoint("abc"),
 		WithMiddleware(EmptyMiddleware()),
 	)
diff --git a/transport/grpc/resolver/discovery/builder_test.go b/transport/grpc/resolver/discovery/builder_test.go
index e1f2d286..7a06abfc 100644
--- a/transport/grpc/resolver/discovery/builder_test.go
+++ b/transport/grpc/resolver/discovery/builder_test.go
@@ -6,30 +6,11 @@ import (
 	"testing"
 	"time"
 
-	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/registry"
 	"google.golang.org/grpc/resolver"
 	"google.golang.org/grpc/serviceconfig"
 )
 
-type mockLogger struct {
-	level log.Level
-	key   string
-	val   string
-}
-
-func (l *mockLogger) Log(level log.Level, keyvals ...interface{}) error {
-	l.level = level
-	l.key = keyvals[0].(string)
-	l.val = keyvals[1].(string)
-	return nil
-}
-
-func TestWithLogger(t *testing.T) {
-	b := &builder{}
-	WithLogger(&mockLogger{})(b)
-}
-
 func TestWithInsecure(t *testing.T) {
 	b := &builder{}
 	WithInsecure(true)(b)
diff --git a/transport/grpc/resolver/discovery/resolver_test.go b/transport/grpc/resolver/discovery/resolver_test.go
index be887899..1d196382 100644
--- a/transport/grpc/resolver/discovery/resolver_test.go
+++ b/transport/grpc/resolver/discovery/resolver_test.go
@@ -7,7 +7,6 @@ import (
 	"testing"
 	"time"
 
-	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/registry"
 	"google.golang.org/grpc/resolver"
 )
@@ -56,7 +55,6 @@ func TestWatch(t *testing.T) {
 	r := &discoveryResolver{
 		w:        &testWatch{},
 		cc:       &testClientConn{te: t},
-		log:      log.NewHelper(log.GetLogger()),
 		ctx:      ctx,
 		cancel:   cancel,
 		insecure: false,
@@ -75,7 +73,6 @@ func TestWatchError(t *testing.T) {
 	r := &discoveryResolver{
 		w:      &testWatch{err: errors.New("bad")},
 		cc:     &testClientConn{te: t},
-		log:    log.NewHelper(log.GetLogger()),
 		ctx:    ctx,
 		cancel: cancel,
 	}
@@ -93,7 +90,6 @@ func TestWatchContextCancel(t *testing.T) {
 	r := &discoveryResolver{
 		w:      &testWatch{err: context.Canceled},
 		cc:     &testClientConn{te: t},
-		log:    log.NewHelper(log.GetLogger()),
 		ctx:    ctx,
 		cancel: cancel,
 	}
diff --git a/transport/grpc/server_test.go b/transport/grpc/server_test.go
index 99a22ffb..5dd779f3 100644
--- a/transport/grpc/server_test.go
+++ b/transport/grpc/server_test.go
@@ -13,7 +13,6 @@ import (
 
 	"github.com/go-kratos/kratos/v2/errors"
 	pb "github.com/go-kratos/kratos/v2/internal/testdata/helloworld"
-	"github.com/go-kratos/kratos/v2/log"
 	"github.com/go-kratos/kratos/v2/middleware"
 	"github.com/go-kratos/kratos/v2/transport"
 
@@ -157,35 +156,6 @@ func TestMiddleware(t *testing.T) {
 	}
 }
 
-type mockLogger struct {
-	level log.Level
-	key   string
-	val   string
-}
-
-func (l *mockLogger) Log(level log.Level, keyvals ...interface{}) error {
-	l.level = level
-	l.key = keyvals[0].(string)
-	l.val = keyvals[1].(string)
-	return nil
-}
-
-func TestLogger(t *testing.T) {
-	o := &Server{}
-	v := &mockLogger{}
-	Logger(v)(o)
-	o.log.Log(log.LevelWarn, "foo", "bar")
-	if !reflect.DeepEqual("foo", v.key) {
-		t.Errorf("expect %s, got %s", "foo", v.key)
-	}
-	if !reflect.DeepEqual("bar", v.val) {
-		t.Errorf("expect %s, got %s", "bar", v.val)
-	}
-	if !reflect.DeepEqual(log.LevelWarn, v.level) {
-		t.Errorf("expect %s, got %s", log.LevelWarn, v.level)
-	}
-}
-
 func TestTLSConfig(t *testing.T) {
 	o := &Server{}
 	v := &tls.Config{}