Switch branches/tags
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src Run google-java-format on all artifacts (#4121) Nov 30, 2018
README.md Release google-cloud-java v0.73.0 (#4191) Dec 7, 2018
pom.xml Bump next snapshot (#4192) Dec 7, 2018

README.md

Logback Appender for Google Cloud Logging

Logback appender com.google.cloud.logging.logback.LoggingAppender for Google Cloud Logging.

This library allows you to use Logback configuration and the Slf4j interface to log via Google Cloud logging.

Note: This client is a work-in-progress, and may occasionally make backwards-incompatible changes.

Quickstart

If you are using Maven, add this to your pom.xml file

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-logging-logback</artifactId>
  <version>0.73.0-alpha</version>
</dependency>

If you are using Gradle, add this to your dependencies

compile 'com.google.cloud:google-cloud-logging-logback:0.73.0-alpha'

If you are using SBT, add this to your dependencies

libraryDependencies += "com.google.cloud" % "google-cloud-logging-logback" % "0.73.0-alpha"

Usage

Add the appender to your Logback configuration logback.xml. See Logback filters for information on filtering log output and encoders for information on formatting.

<configuration>
  <appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
    <!-- Optional : filter logs at or above a level -->
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>INFO</level>
    </filter>
    <log>application.log</log> <!-- Optional : default java.log -->
    <enhancer>com.example.enhancers.TestLoggingEnhancer</enhancer> <!-- Optional -->
    <enhancer>com.example.enhancers.AnotherEnhancer</enhancer> <!-- Optional -->
    <flushLevel>WARN</flushLevel> <!-- Optional : default ERROR -->
  </appender>

  <root level="info">
    <appender-ref ref="CLOUD" />
  </root>
</configuration>

In your code :

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class TestLogger {
    private final Logger logger = LoggerFactory.getLogger(TestLogger.class);
 
    public void log(String name) {
        logger.info("This is a test");
    }

    public static void main(String[] args) {
        TestLogger testLogger = new TestLogger();
        testLogger.log("test");
    }
}

Authentication

See the Authentication section in the base directory's README.

Limitations

This library is usable, but not yet complete. Open issues here.

Java Versions

Java 7 or above is required for using this client.

Versioning

This library follows Semantic Versioning.

It is currently in major version zero (0.y.z), which means that anything may change at any time and the public API should not be considered stable.

Contributing

Contributions to this library are always welcome and highly encouraged.

See google-cloud's CONTRIBUTING documentation and the shared documentation for more information on how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.

License

Apache 2.0 - See LICENSE for more information.