我想在我的 Ruby 应用程序上禁用 NewRelic 日志,但只能在 test
环境中禁用。
由于在文档中我们只有要设置的日志级别,而且我想避免任何日志记录,是否有任何选项可以用来禁用它们?
这是我的 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
最佳答案
经过一番阅读,我找到了这篇文章:https://discuss.newrelic.com/t/stop-logging-in-newrelic-agent-log-file/39876/3
我已经修改了 yaml
的代码并以:
test:
<<: *default_settings
# It doesn't make sense to report to New Relic from automated test runs.
monitor_mode: false
logging:
enabled: false
现在问题解决了!
关于ruby - 如何禁用 NewRelic 日志,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45736723/