An open API service indexing awesome lists of open source software.

https://github.com/getlantern/exceptional4j

Uses Exceptional to report Java exceptions
https://github.com/getlantern/exceptional4j

Last synced: 8 months ago
JSON representation

Uses Exceptional to report Java exceptions

Awesome Lists containing this project

README

          

This is a project integrating the log4j logger with Exceptional to report a configurable number of log errors to Exceptional. Exceptional4j is licensed under the Apache 2 license.

To include it with maven, you can do:

```

org.getlantern
exceptional4j
0.1-SNAPSHOT

```

We'll sync it with Maven central as soon as it's stable, but until then you need to add the Sonatype SNAPSHOTS repo if you don't already include it, as in:

```

sonatype-nexus-snapshots
Sonatype Nexus Snapshots

https://oss.sonatype.org/content/repositories/snapshots


false


true


```

Exceptional4j is currently set up to be integrated programmatically when your application first loads, for example:

```
private void configureProductionLogger() {
final File logFile = new File("/var/log/myapp.log");
final Properties props = new Properties();
try {
final String logPath = logFile.getCanonicalPath();
props.put("log4j.appender.RollingTextFile.File", logPath);
props.put("log4j.rootLogger", "warn, RollingTextFile");
props.put("log4j.appender.RollingTextFile",
"org.apache.log4j.RollingFileAppender");

PropertyConfigurator.configure(props);
final ExceptionalAppenderCallback callback =
new ExceptionalAppenderCallback() {
@Override
public boolean addData(final JSONObject json, final LoggingEvent le) {
json.put("version", LanternConstants.VERSION);
return true;
}
};
final Appender bugAppender = new ExceptionalAppender(
"YOUR_API_KEY", callback);
BasicConfigurator.configure(bugAppender);
} catch (final IOException e) {
System.out.println("Exception setting log4j props with file: "
+ logFile);
e.printStackTrace();
}
}
```