From 8d591a2793f762a72847a4217e38f797eb7f0d5d Mon Sep 17 00:00:00 2001 From: "Christian Mauduit (DataDog)" Date: Fri, 9 Jun 2017 14:10:19 -0400 Subject: [PATCH 1/2] [doc] showing how to use a custom logger --- docs/GettingStarted.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 83e06ec7f3f..da82b15bf70 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -479,6 +479,21 @@ for the first time: Remember that the debug mode may affect your application performance and so it must not be used in a production environment. +### Using a custom logger + +By default, all logs are processed by the default Ruby logger. +Typically, when using Rails, you should see the messages in your application log file. +Datadog client log messages are marked with ``[ddtrace]`` so you should be able +to isolate them from other messages. + +Additionally, it is possible to override the default logger and replace it by a +custom one. This is done using the ``log`` attribute of the tracer. + + buf = StringIO.new # Log messages should go there + Datadog::Tracer.log = Logger.new(buf) # Overriding the default tracer + Datadog::Tracer.log.info { "this is typically called by tracing code" } + puts buf.string # Print all our custom log content + ### Environment and tags By default, the trace agent (not this library, but the program running in From 3dbe8f89a16a651e08a277777b6015631b75cee4 Mon Sep 17 00:00:00 2001 From: "Christian Mauduit (DataDog)" Date: Fri, 9 Jun 2017 16:43:21 -0400 Subject: [PATCH 2/2] [doc] rewrote example using a custom logger that writes to a file --- docs/GettingStarted.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index da82b15bf70..47539c9312a 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -489,10 +489,9 @@ to isolate them from other messages. Additionally, it is possible to override the default logger and replace it by a custom one. This is done using the ``log`` attribute of the tracer. - buf = StringIO.new # Log messages should go there - Datadog::Tracer.log = Logger.new(buf) # Overriding the default tracer + f = File.new("my-custom.log", "w+") # Log messages should go there + Datadog::Tracer.log = Logger.new(f) # Overriding the default tracer Datadog::Tracer.log.info { "this is typically called by tracing code" } - puts buf.string # Print all our custom log content ### Environment and tags