Code Monkey home page Code Monkey logo

Comments (2)

zUniQueX avatar zUniQueX commented on June 28, 2024 1

Hi @JamesBoon. The config overrides only accept simple string values and arrays of strings. Hence, they cannot be used to override the whole appenders object.

The filter factories also work for other commands since they reside in dropwizard-logging and don't depend on any logic related to the server command. The docs only provide an example for a FilterFactory<IAccessEvent> that is indeed only related to request logging within the server command. To obtain a filter factory for a "normal" appender rather than a request log appender, you'll need to provide a FilterFactory<ILoggingEvent>.

I think the simplest solution for your use case is to use environment variables for the logging levels of the appenders. Then you can provide an environment variable with the value OFF to disable logging for the other appenders.

from dropwizard.

JamesBoon avatar JamesBoon commented on June 28, 2024

Thank you @zUniQueX, that was the hint I needed!

If anyone else needs it:

appenders:
  - type: console
    threshold: ${DW_LOG_THRESHOLD_CONSOLE:-OFF}
    # ...
  - type: file
    threshold: ${DW_LOG_THRESHOLD_FILE:-INFO}
    # ...

This way, the console logger is OFF by default, but can be switched on by setting the environment variable DW_LOG_THRESHOLD_CONSOLE to any log level like e.g. INFO.
The file logger is on by default and can be switched off by setting DW_LOG_THRESHOLD_FILE=OFF.

Just before anybody asks, yes the same thing can be achieved via passing system properties. But this should only be used if the number and order of the log appenders is always fixed!
-Ddw.logging.appenders[0].threshold=INFO -Ddw.logging.appenders[1].threshold=OFF

from dropwizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.