Skip to content

Commit cad5744

Browse files
committed
[DOCS] Adds info for ECS logging
1 parent a9e963a commit cad5744

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

elasticsearch-transport/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,24 @@ Elasticsearch::Client.new(
187187

188188
### Logging
189189

190-
To log requests and responses to standard output with the default logger (an instance of Ruby's {::Logger} class),
191-
set the `log` argument:
190+
To log requests and responses to standard output with the default logger (an instance of Ruby's {::Logger} class), set the `log` argument to true:
192191

193192
```ruby
194-
Elasticsearch::Client.new log: true
193+
Elasticsearch::Client.new(log: true)
194+
```
195+
196+
You can also use [ecs-logging](https://github.com/elastic/ecs-logging-ruby). `ecs-logging` is a set of libraries that allows you to transform your application logs to structured logs that comply with the [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html):
197+
198+
```ruby
199+
logger = EcsLogging::Logger.new($stdout)
200+
Elasticsearch::Client.new(logger: logger)
195201
```
196202

197203

198204
To trace requests and responses in the _Curl_ format, set the `trace` argument:
199205

200206
```ruby
201-
Elasticsearch::Client.new trace: true
207+
Elasticsearch::Client.new(trace: true)
202208
```
203209

204210
You can customize the default logger or tracer:
@@ -211,7 +217,7 @@ You can customize the default logger or tracer:
211217
Or, you can use a custom `::Logger` instance:
212218

213219
```ruby
214-
Elasticsearch::Client.new logger: Logger.new(STDERR)
220+
Elasticsearch::Client.new(logger: Logger.new(STDERR))
215221
```
216222

217223
You can pass the client any conforming logger implementation:
@@ -223,7 +229,7 @@ log = Logging.logger['elasticsearch']
223229
log.add_appenders Logging.appenders.stdout
224230
log.level = :info
225231

226-
client = Elasticsearch::Client.new logger: log
232+
client = Elasticsearch::Client.new(logger: log)
227233
```
228234

229235
### Custom HTTP Headers

0 commit comments

Comments
 (0)