airbrake-logback

Logback Appender for Airbrake

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка Сеть Logback Библиотеки уровня приложения Logging
Группа

Группа

net.anthavio
Идентификатор

Идентификатор

airbrake-logback
Последняя версия

Последняя версия

1.0.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

airbrake-logback
Logback Appender for Airbrake
Организация-разработчик

Организация-разработчик

Anthavio
Система контроля версий

Система контроля версий

https://github.com/anthavio/airbrake-logback

Скачать airbrake-logback

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.anthavio/airbrake-logback/ -->
<dependency>
    <groupId>net.anthavio</groupId>
    <artifactId>airbrake-logback</artifactId>
    <version>1.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/net.anthavio/airbrake-logback/
implementation 'net.anthavio:airbrake-logback:1.0.3'
// https://jarcasting.com/artifacts/net.anthavio/airbrake-logback/
implementation ("net.anthavio:airbrake-logback:1.0.3")
'net.anthavio:airbrake-logback:jar:1.0.3'
<dependency org="net.anthavio" name="airbrake-logback" rev="1.0.3">
  <artifact name="airbrake-logback" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.anthavio', module='airbrake-logback', version='1.0.3')
)
libraryDependencies += "net.anthavio" % "airbrake-logback" % "1.0.3"
[net.anthavio/airbrake-logback "1.0.3"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
ch.qos.logback : logback-classic jar 1.1.1
javax.servlet : servlet-api Необязательный jar 2.4
io.airbrake : airbrake-java jar 2.2.8

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.assertj : assertj-core jar 1.7.1
org.mockito : mockito-all jar 1.10.19
org.springframework : spring-test jar 3.2.18.RELEASE

Модули Проекта

Данный проект не имеет модулей.

airbrake-logback

Build Status Coverage Status Maven Central

Logback Appender for Airbrake

Built on the top of the official airbrake.io library adding Logback Appender

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="30 seconds">

	<appender name="AIRBRAKE" class="net.anthavio.airbrake.AirbrakeLogbackAppender">
		<apiKey>YOUR_AIRBRAKE_API_KEY</apiKey>
		<env>test</env>
		<enabled>true</enabled>

		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>ERROR</level>
		</filter>
	</appender>

	<root>
		<level value="info" />
		<appender-ref ref="AIRBRAKE" />
	</root>
	
</configuration>

Additionaly to airbrake.io library functionality, airbrake-logback also can send simple one line error messages without stacktraces. Source code line, where error was logged, is still captured and sent to Airbrake.

Configure it setting <notify>ALL</notify> in logback.xml Possible values are ALL, EXCEPTIONS, OFF

	<appender name="AIRBRAKE" class="net.anthavio.airbrake.AirbrakeLogbackAppender">
		<apiKey>YOUR_AIRBRAKE_API_KEY</apiKey>
		<env>test</env>
		<notify>ALL</notify>
		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>ERROR</level>
		</filter>
	</appender>

Java code

Logger logger = LoggerFactory.getLogger(getClass());
logger.error("I'm going to Airbrake! Exact line will be there too");

HTTP request and session integration

If you happen to use library in Servlet container you can have HTTP request and session information included in Airbrake notifications. To enable it you have to add AirbrakeServletRequestFilter into your configuration web.xml exmple

  <filter> 
    <filter-name>AirbrakeFilter</filter-name>
    <filter-class>net.anthavio.airbrake.http.AirbrakeServletRequestFilter</filter-class> 
  </filter> 
  <filter-mapping> 
    <filter-name>AirbrakeFilter</filter-name>
    <url-pattern>/*</url-pattern> 
  </filter-mapping> 

Spring Boot @Configuration example

	@Bean
	public FilterRegistrationBean airbrakeFilter() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(new AirbrakeServletRequestFilter());
		registration.addUrlPatterns("/*");
		return registration;
	}

In case you are unhappy with provided AirbrakeServletRequestFilter and HttpServletRequestEnhancer, you can implement your own...

package com.example;
import net.anthavio.airbrake.AirbrakeNoticeBuilderUsingFilteredSystemProperties;
import net.anthavio.airbrake.http.RequestEnhancer;
import net.anthavio.airbrake.http.RequestEnhancerFactory;

// Simpe example implementation
public class HackyEnhancerFactory implements RequestEnhancerFactory {

    @Override
    public RequestEnhancer get() {
        return new HackyEnhancer();
    }

    static class HackyEnhancer implements RequestEnhancer<Void> {

        @Override
        public void setRequest(Void request) {
            // nothing
        }

        @Override
        public void endRequest(Void request) {
            // nothing
        }

        @Override
        public void enhance(AirbrakeNoticeBuilderUsingFilteredSystemProperties builder) {
            builder.setRequest("http://localhost","");
        }
    }
}

and then configure it in logback.xml using

	<appender name="AIRBRAKE" class="net.anthavio.airbrake.AirbrakeLogbackAppender">
		<apiKey>YOUR_AIRBRAKE_API_KEY</apiKey>
		<env>test</env>
		<notify>ALL</notify>
		<requestEnhancerFactory>com.example.HackyEnhancerFactory</requestEnhancerFactory>
		
		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>ERROR</level>
		</filter>
	</appender>

Версии библиотеки

Версия
1.0.3
1.0.2
1.0.1
1.0.0