# Logging

### Configuration

```yaml
asjard:
  ## log configuration
  logger:
    ## supports: DEBUG,INFO,WARN,ERROR,Case insensitive
    # level: INFO
    ## log format, supports: text,json
    # format: json
    ## log file path
    # filePath: /dev/stdout
    ## Log rotation prevention configuration
    ## File size (in MB)
    # maxSize: 100
    ## Maximum number of days to retain a file.
    # maxAge: 0
    ## Maximum number of backups.
    # maxBackups: 10
    ## Whether to compress
    # compress: true
    ## access log configuration
    accessLog:
      ## enable access log
      # enabled: false
      ## format: [protocol://]{fullMethod}
      ## include specified protocol and method: grpc:///api.v1.hello.Hello/Call
      ## include a protocol-independent method: /api.v1.hello.Hello/Call
      ## include all grpc proto: grpc
      # skipMethods:
      # - grpc
      ## other configurations same as asjard.logger
    ## gorm log configuration
    gorm:
      # ignoreRecordNotFoundError: false
      # slowThreshold: 200ms
      ## other configurations same as asjard.logger
    ## banner log
    banner:
      ## if enabled it will print the banner message after server start.
      # enabled: true
```

### Use

```go
import "github.com/asjard/asjard/core/logger"

func (api *SampleAPI) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
	logger.Debug("say hello request", "name", name)
	// or a logger with trace context
	logger.L(ctx).Debug("say hello request", "name", name)
	return &pb.HelloReply{
		Message: "hello " + in.Name,
	}, nil
}
```
