How to disable NewRelic logs
Asked Answered
L

2

6

I would like to disable NewRelic logs on my Ruby application, but only on test environment. Since in the documentation we only have the log levels to set, and I want to avoid any logging, is there any option I can use to disable them?

Here is my newrelic.yml:

#
# This file configures the New Relic Agent.  New Relic monitors Ruby, Java,
# .NET, PHP, Python and Node applications with deep visibility and low
# overhead.  For more information, visit www.newrelic.com.
#
# Generated April 27, 2016, for version 3.15.2.317
#
# For full documentation of agent configuration options, please refer to
# https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration

common: &default_settings
  # Required license key associated with your New Relic account.
  license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %>

  # Your application name. Renaming here affects where data displays in New
  # Relic.  For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'Components' %>

  # To disable the agent regardless of other settings, uncomment the following:
  # agent_enabled: false
  #
  # Enable or disable the transmission of data to the New Relic collector).
  monitor_mode: <%= ENV["NO_INSTRUMENTATION"] == '1' ? false : true %>

  # Log level for agent logging: error, warn, info or debug.
  log_level: <%= ENV["NEW_RELIC_DEBUG_LEVEL"] || 'info' %>

  # Enable or disable SSL for transmissions to the New Relic collector).
  # Defaults to true in versions 3.5.6 and higher.
  ssl: true

  # Enable or disable high security mode, a suite of security features
  high_security: false

  # Enable or disable synchronous connection to the New Relic data collection
  # service during application startup.
  sync_startup: false

  # Enable or disable the exit handler that sends data to the New Relic
  # collector) before shutting down.
  send_data_on_exit: true

  # Maximum number of seconds to attempt to contact the New Relic collector).
  timeout: 120

  # =============================== Transaction Tracer ================================
  #
  # The transaction traces feature collects detailed information from a
  # selection of transactions, including a summary of the calling sequence, a
  # breakdown of time spent, and a list of SQL queries and their query plans
  # (on mysql and postgresql). Available features depend on your New Relic
  # subscription level.
  transaction_tracer:

    # Enable or disable transaction traces.
    enabled: true

    # The agent will collect traces for transactions that exceed this time
    # threshold (in seconds). Specify a float value or apdex_f.
    #
    # apdex_f is the response time above which a transaction is considered
    # "frustrating." Defaults to four times apdex_t. Requests which complete
    # in less than apdex_t are rated satisfied. Requests which take more than
    # apdex_t, but less than four times apdex_t (apdex_f), are tolerated. Any
    # requests which take longer than apdex_f are rated frustrated.
    transaction_threshold: <%= ENV['NEW_RELIC_TRANSACTION_THRESHOLD'] || 'apdex_f' %>

    # Determines whether Redis command arguments should be recorded within
    # Transaction Traces.
    record_redis_arguments: false

    # Threshold (in seconds) above which the agent will collect explain plans.
    # Relevant only when explain_enabled is true.
    explain_threshold: 0.2

    # Enable or disable the collection of explain plans in transaction traces.
    # This setting will also apply to explain plans in Slow SQL traces if
    # slow_sql.explain_enabled is not set separately.
    explain_enabled: true

    # Stack traces will be included in transaction trace nodes when their duration
    # exceeds this threshold.
    stack_trace_threshold: 0.5

    # Maximum number of transaction trace nodes to record in a single
    # transaction trace.
    limit_segments: 4000

  # =============================== Error Collector ================================
  #
  # The agent collects and reports all uncaught exceptions by default. These
  # configuration options allow you to customize the error collection.
  error_collector:

    # Enable or disable recording of traced errors and error count metrics.
    enabled: true

  # ============================== Heroku ===============================
  heroku:
    use_dyno_names: true

  # ============================== Thread Profiler ===============================
  thread_profiler:
    enabled: true

# Environment-specific settings are in this section.
# RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
# If your application has other named environments, configure them here.
development:
  <<: *default_settings
  app_name: Orchestrator (Development)

  # NOTE: There is substantial overhead when running in developer mode.
  # Do not use for production or load testing.
  developer_mode: true

test:
  <<: *default_settings
  # It doesn't make sense to report to New Relic from automated test runs.
  monitor_mode: false

staging:
  <<: *default_settings
  app_name: Components (Staging)

production:
  <<: *default_settings
Lorielorien answered 17/8, 2017 at 13:39 Comment(1)
Please share your newrelic.ymlAlleyn
L
8

After some reading, I've found this post: https://discuss.newrelic.com/t/stop-logging-in-newrelic-agent-log-file/39876/3

I've adapted the code for yaml and ended with:

test:
  <<: *default_settings
  # It doesn't make sense to report to New Relic from automated test runs.
  monitor_mode: false
  logging:
    enabled: false

and the problem is now solved!

Lorielorien answered 17/8, 2017 at 13:52 Comment(2)
The settings for the Ruby agent that resolved your issue are documented at New Relic, along with all other options available for the agent.Baguio
@Baguio I don't see the logging option, I only see options to control the logging like level, files, etc.Lorielorien
D
2

You have log_level: off

Also a "hacky way", if you don't have log folder it won't write log...

the current working directory should contain a log directory

Danas answered 17/8, 2017 at 13:51 Comment(1)
This options also works, althouht in the documentation we have: Possible log levels, in increasing verbosity, are: error, warn, info or debugLorielorien

© 2022 - 2024 — McMap. All rights reserved.