Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaLoggingLogback errors do not appear in StackDriver Error Reporting #30

Closed
rich-j opened this issue Jan 22, 2020 · 0 comments · Fixed by #43
Closed

JavaLoggingLogback errors do not appear in StackDriver Error Reporting #30

rich-j opened this issue Jan 22, 2020 · 0 comments · Fixed by #43
Assignees
Labels
api: logging Issues related to the googleapis/java-logging-logback API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@rich-j
Copy link

rich-j commented Jan 22, 2020

The documentation for StackDriver Java Error Reporting states:

Exceptions logged using the Stackdriver Logback Appender ... are automatically reported to the Error Reporting console.

None of our logged errors appear in Error Reporting (not that we have many :-) .

We are using Java 11 in App Engine Standard with version 0.116.0-alpha of this google-cloud-logging-logback appender. Our logback.xml configuration is:

<appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
  <log>application.log</log>
  <resourceType>gae_app</resourceType> <!-- Optional : default global -->
  <flushLevel>WARN</flushLevel> <!-- Optional : default ERROR -->
</appender>

We did a quick experiment using Formatting errors in Stackdriver Logging and were able to get errors reported by changing the appender to submit JSON and add the @type value for errors:

private LogEntry logEntryFor(ILoggingEvent e) {
    StringBuilder payload = new StringBuilder(e.getFormattedMessage()).append('\n');
    writeStack(e.getThrowableProxy(), "", payload);

    Level level = e.getLevel();
    Severity severity = severityFor(level);

    Map<String, Object> jsonContent = new HashMap<String, Object>();
    jsonContent.put("message", payload.toString().trim());
    if (severity == Severity.ERROR)
      jsonContent.put("@type", "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent");

    LogEntry.Builder builder =
        LogEntry.newBuilder(Payload.JsonPayload.of(jsonContent))
            .setTimestamp(e.getTimeStamp())
            .setSeverity(severity);

...

Having logged errors appear in Error Reporting is important for any production server.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Jan 23, 2020
@chingor13 chingor13 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 28, 2020
@yoshi-automation yoshi-automation removed triage me I really want to be triaged. 🚨 This issue needs some love. labels Jan 28, 2020
@google-cloud-label-sync google-cloud-label-sync bot added the api: logging Issues related to the googleapis/java-logging-logback API. label Jan 30, 2020
@athakor athakor self-assigned this Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging-logback API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants