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
- Host: GitHub
- URL: https://github.com/getlantern/exceptional4j
- Owner: getlantern
- License: apache-2.0
- Created: 2011-10-11T23:31:49.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T17:26:29.000Z (over 1 year ago)
- Last Synced: 2025-07-04T14:40:13.694Z (12 months ago)
- Language: Java
- Homepage:
- Size: 60.5 KB
- Stars: 4
- Watchers: 9
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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();
}
}
```