2017-08-17 166 views
1

我想在我的Ruby应用程序上禁用NewRelic日志,但仅在test环境中禁用。 由于在文档中我们只有日志级别设置,并且我想避免任何日志记录,有没有我可以用来禁用它们的选项?如何禁用NewRelic日志

这里是我的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 
+0

请分享你的'newrelic.yml' – Salil

回答

1

你有log_level: off

也有 “哈克的方式”,如果你没有log folder也不会写日志做...

当前工作目录应包含日志目录

+0

这个选项也适用,althouht的文档中,我们有: 可能的日志级别,增加冗长,分别是:错误,警告,信息或调试 –

2

一些阅读之后,我发现这个职位: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 

,问题就解决了,现在!

+0

为Ruby代理的设置,解决您的问题[在New Relic记录](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration#general),以及代理可用的所有其他选项。 – anothermh

+0

@anothermh我没有看到日志记录选项,我只能看到选项来控制级别,文件等日志记录。 –