jordansissel / ruby-cabin

Structured+contextual logging experiments in Ruby
Other
153 stars 22 forks source link

add configuration file support #46

Open fbaligand opened 8 years ago

fbaligand commented 8 years ago

It would be really great to add the ability to set a configuration file which defines loglevel for each logger, and also which output(s) to use.

Something like log4j.xml for example :

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="debug" strict="true" name="XMLConfigTest"
                   packages="org.apache.logging.log4j.test">
      <Appenders>
        <Appender type="Console" name="STDOUT">
          <Layout type="PatternLayout" pattern="%m MDC%X%n"/>
        </Appender>
        <Appender type="File" name="File" fileName="${filename}">
          <Layout type="PatternLayout">
            <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
          </Layout>
        </Appender>
      </Appenders>

      <Loggers>
        <Logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
          <AppenderRef ref="STDOUT"/>
        </Logger>

        <Logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
          <AppenderRef ref="File"/>
        </Logger>

        <Root level="trace">
          <AppenderRef ref="File"/>
        </Root>
      </Loggers>

    </Configuration>