Michael Vorburger.ch Blog

Javas

2026

How to log to Google Cloud Logging as JSON from Java with SLF4j

March 6, 2026

How to log to Google Cloud Logging as JSON from Java with SLF4j

Add https://github.com/logfellow/logstash-logback-encoder and put this into your logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!-- Use JSON format for scalable logging suitable for Google Cloud Logging -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
            <!-- logstash-logback-encoder writes timestamps in the default TimeZone of the JVM, but GCP wants UTC -->
            <timeZone>UTC</timeZone>

            <!-- Align field names with Google Cloud Structured Logging requirements;
                 see https://docs.cloud.google.com/logging/docs/structured-logging,
                 and https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry. -->
            <fieldNames>
                <!-- GCP expects 'timestamp', logstash-logback-encoder defaults to '@timestamp' -->
                <timestamp>timestamp</timestamp>

                <!-- GCP expects 'severity', logstash-logback-encoder defaults to 'level' -->
                <level>severity</level>

                <!-- Ignore levelValue as severity is sufficient for GCP -->
                <levelValue>[ignore]</levelValue>

                <!-- Disable logstash-logback-encoder's '@version' field as GCP doesn't use it -->
                <version>[ignore]</version>

                <!-- GCP expects 'message' which is the default for logstash-logback-encoder -->
            </fieldNames>
        </encoder>
    </appender>

    <!-- Wrap STDOUT in AsyncDisruptorAppender for better performance, decoupling logging from I/O -->
    <appender name="ASYNC_STDOUT" class="net.logstash.logback.appender.LoggingEventAsyncDisruptorAppender">
        <appender-ref ref="STDOUT" />
    </appender>

    <!-- Suppress verbose internal logging from certain libraries if needed -->
    <!-- <logger name="org.apache" level="WARN" /> -->

    <root level="INFO">
        <appender-ref ref="ASYNC_STDOUT" />
    </root>
</configuration>

Alternatives:

2024

OpenJDK JIRA

August 26, 2024

OpenJDK JIRA

The JIRA instance of the OpenJDK at https://bugs.openjdk.org is “open” in the sense that many of its issues are publicly viewable.

In order to be able to create an account to file new issues, or comment on existing ones etc., one must however necessarily first already be an author in the external OpenJDK project, see this doc and the bylaws. (There may also be some path through which one can start submitting something via https://bugreport.java.com/bugreport, and that then may or may not somehow end up over on https://bugs.openjdk.org; I’ve not further explored that.)

2023

Java JDK Source Code in Visual Studio Code

January 29, 2023

Java JDK Source Code in Visual Studio Code

I’ve switched from using Eclipse to Visual Studio Code (VSC) for Java coding, and was missing the JDK Source Code in VSC.

The discussion in this bug didn’t help, because the problem was the following:

It appears that the Language Support for Java by Red Hat CSV extension “helps” users with its (Ctrl-Shift-P) Install New JDK UI feature. Those get installed into ~/.vscode/extensions/redhat.java-1.14.0-linux-x64/jre, are entirely separate from any “system package” JDK installs - and do not appear to include the src.zip with JDK source code (at least some of them, such as Eclipse Adoptium’s Temurin).