Skip to content

Commit

Permalink
Merge pull request #140 from bugsnag/catch-logback-classdef-error
Browse files Browse the repository at this point in the history
Swallow Throwables thrown when configuring bugsnag appender
  • Loading branch information
fractalwrench authored Apr 12, 2019
2 parents 777edf4 + bcb9669 commit a331f30
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.X.X (TBD)

* Swallow Throwables thrown when configuring bugsnag appender
[#140](https://github.com/bugsnag/bugsnag-java/pull/140)

## 3.4.5 (2019-04-04)

* Migrate non-standard device fields to metaData.device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,26 @@ ScheduledTaskBeanLocator scheduledTaskBeanLocator() {
* messages as they effectively duplicate error reports for unhandled exceptions.
*/
@PostConstruct
@SuppressWarnings("checkstyle:emptycatchblock")
void excludeLoggers() {
// Exclude Tomcat logger when processing HTTP requests via a servlet.
// Regex specified to match the servlet variable parts of the logger name, e.g.
// the Spring Boot default is:
// [Tomcat].[localhost].[/].[dispatcherServlet]
// but could be something like:
// [Tomcat-1].[127.0.0.1].[/subdomain/].[customDispatcher]
BugsnagAppender.addExcludedLoggerPattern("org.apache.catalina.core.ContainerBase."
+ "\\[Tomcat.*\\][.]\\[.*\\][.]\\[/.*\\][.]\\[.*\\]");
try {
// Exclude Tomcat logger when processing HTTP requests via a servlet.
// Regex specified to match the servlet variable parts of the logger name, e.g.
// the Spring Boot default is:
// [Tomcat].[localhost].[/].[dispatcherServlet]
// but could be something like:
// [Tomcat-1].[127.0.0.1].[/subdomain/].[customDispatcher]
BugsnagAppender.addExcludedLoggerPattern("org.apache.catalina.core.ContainerBase."
+ "\\[Tomcat.*\\][.]\\[.*\\][.]\\[/.*\\][.]\\[.*\\]");

// Exclude Jetty logger when processing HTTP requests via the HttpChannel
BugsnagAppender.addExcludedLoggerPattern("org.eclipse.jetty.server.HttpChannel");
// Exclude Jetty logger when processing HTTP requests via the HttpChannel
BugsnagAppender.addExcludedLoggerPattern("org.eclipse.jetty.server.HttpChannel");

// Exclude Undertow logger when processing HTTP requests
BugsnagAppender.addExcludedLoggerPattern("io.undertow.request");
// Exclude Undertow logger when processing HTTP requests
BugsnagAppender.addExcludedLoggerPattern("io.undertow.request");
} catch (NoClassDefFoundError ignored) {
// logback was not in classpath, ignore throwable to allow further initialisation
}
}

}

0 comments on commit a331f30

Please sign in to comment.