Skip to content

Latest commit

 

History

History
75 lines (64 loc) · 2.61 KB

README.md

File metadata and controls

75 lines (64 loc) · 2.61 KB

hawtio-logback

Quick-And-Dirty approach in order to provide 'LogQuery'-Support (see: https://github.com/fabric8io/fabric8/tree/master/insight/insight-log-core) for Logback.

The Approach is mainly influenced by the insight-log4j project (see: https://github.com/fabric8io/fabric8/tree/master/insight/insight-log4j)

Why

In our project we simply wanted to access our most-recent (Logback-Based) log outputs from within the 'Hawtio' app

Open Items

* Add Maven Coordinates Support * Add Better Predicate Filtering Support * CallerData is not always determined correclty

Howto Integrate

DefaultCyclicBufferAppender

The DefaultCyclicBufferAppender keeps N-Log-Events in-memory.

Spring-Annotation-Config

@Configuration
public class LogbackLogQueryConfig {
    @Bean
    public LogbackLogQuery createLogbackAwareLogQueryMBeanImpl() {
        return new LogbackLogQuery(new CyclicBufferAppenderWrapper(new CyclicBufferAppender<ILoggingEvent>(), 10));
    }
}

Spring-XML-Config

```xml
<bean class="ch.mimacom.log.logback.LogbackLogQuery"
      init-method="start"
      destroy-method="stop">
    <constructor-arg name="logQueryAwareAppender">
        <bean class="ch.mimacom.log.logback.appender.CyclicBufferAppenderWrapper">
            <bean class="ch.qos.logback.core.read.CyclicBufferAppender">
               <constructor-arg name="maxSize" value="10"/>
            </bean>
        </bean>
    </constructor-arg>
</bean>
```

LevelBasedCyclicBufferAppender

Allows to define a buffer-size for each level. Thus N-Log-Events for every Level are keept in-memory

Spring-Annotation-Config

```java @Configuration public class LogbackLogQueryConfig { @Bean public LogbackAwareLogQueryMBeanImpl createLogbackAwareLogQueryMBeanImpl() { return new LogbackLogQuery( new LevelBasedCyclicBufferAppender( ImmutableMap.builder() .put("TRACE", 256) .put("DEBUG", 256) .put("INFO", 1024) .put("WARN", 1024) .put("ERROR", 1024) .build() ) ); } } ```