|
| 1 | +Logback Appender for Google Cloud Logging |
| 2 | +========================================= |
| 3 | + |
| 4 | +Logback appender `com.google.cloud.logging.logback.LoggingAppender` for |
| 5 | +[Google Cloud Logging](https://cloud.google.com/logging/). |
| 6 | + |
| 7 | +This library allows you to use [Logback](https://logback.qos.ch/) configuration and the [Slf4j](https://www.slf4j.org/) interface to log via Google Cloud logging. |
| 8 | + |
| 9 | +- [Homepage](https://googlecloudplatform.github.io/google-cloud-java/) |
| 10 | +- [API Documentation](https://googlecloudplatform.github.io/google-cloud-java/apidocs/index.html?com/google/cloud/logging/logback/LoggingAppender.html) |
| 11 | + |
| 12 | +> Note: This client is a work-in-progress, and may occasionally |
| 13 | +> make backwards-incompatible changes. |
| 14 | +
|
| 15 | +Quickstart |
| 16 | +---------- |
| 17 | +If you are using Maven, add this to your pom.xml file |
| 18 | +```xml |
| 19 | +<dependency> |
| 20 | + <groupId>com.google.cloud</groupId> |
| 21 | + <artifactId>google-cloud-logging-logback</artifactId> |
| 22 | + <version>0.18.0-alpha</version> |
| 23 | +</dependency> |
| 24 | +``` |
| 25 | +If you are using Gradle, add this to your dependencies |
| 26 | +```Groovy |
| 27 | +compile 'com.google.cloud:google-cloud-logging-logback:0.18.0-alpha' |
| 28 | +``` |
| 29 | +If you are using SBT, add this to your dependencies |
| 30 | +```Scala |
| 31 | +libraryDependencies += "com.google.cloud" % "google-cloud-logging-logback" % "0.18.0-alpha" |
| 32 | +``` |
| 33 | + |
| 34 | +Usage |
| 35 | +----- |
| 36 | + |
| 37 | +Add the appender to your [Logback configuration](https://logback.qos.ch/manual/configuration.html) `logback.xml`. |
| 38 | +See [Logback filters](https://logback.qos.ch/manual/filters.html#thresholdFilter) for information on filtering log output and |
| 39 | + [encoders](https://logback.qos.ch/manual/encoders.html) for information on formatting. |
| 40 | + |
| 41 | + |
| 42 | +```xml |
| 43 | +<configuration> |
| 44 | + <appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender"> |
| 45 | + <!-- Optional : filter logs at or above a level --> |
| 46 | + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
| 47 | + <level>INFO</level> |
| 48 | + </filter> |
| 49 | + <log>application.log</log> <!-- Optional : default java.log --> |
| 50 | + <enhancer>com.example.enhancers.TestLoggingEnhancer</enhancer> <!-- Optional --> |
| 51 | + <enhancer>com.example.enhancers.AnotherEnhancer</enhancer> <!-- Optional --> |
| 52 | + <flushLevel>WARN</flushLevel> <!-- Optional : default ERROR --> |
| 53 | + </appender> |
| 54 | + |
| 55 | + <root level="info"> |
| 56 | + <appender-ref ref="CLOUD" /> |
| 57 | + </root> |
| 58 | +</configuration> |
| 59 | +``` |
| 60 | + |
| 61 | +In your code : |
| 62 | + |
| 63 | +```java |
| 64 | +import org.slf4j.Logger; |
| 65 | +import org.slf4j.LoggerFactory; |
| 66 | + |
| 67 | +public class TestLogger { |
| 68 | + private final Logger logger = LoggerFactory.getLogger(TestLogger.class); |
| 69 | + |
| 70 | + public void log(String name) { |
| 71 | + logger.info("This is a test"); |
| 72 | + } |
| 73 | + |
| 74 | + public static void main(String[] args) { |
| 75 | + TestLogger testLogger = new TestLogger(); |
| 76 | + testLogger.log("test"); |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | + |
| 82 | +Authentication |
| 83 | +-------------- |
| 84 | + |
| 85 | +See the [Authentication](https://github.com/GoogleCloudPlatform/google-cloud-java#authentication) |
| 86 | +section in the base directory's README. |
| 87 | + |
| 88 | + |
| 89 | +Limitations |
| 90 | +----------- |
| 91 | + |
| 92 | +This library is usable, but not yet complete. |
| 93 | +Open issues [here](https://github.com/GoogleCloudPlatform/google-cloud-java/issues?q=is%3Aissue+is%3Aopen+label%3A%22logging-logback%22). |
| 94 | + |
| 95 | + |
| 96 | +Java Versions |
| 97 | +------------- |
| 98 | + |
| 99 | +Java 7 or above is required for using this client. |
| 100 | + |
| 101 | +Versioning |
| 102 | +---------- |
| 103 | + |
| 104 | +This library follows [Semantic Versioning](http://semver.org/). |
| 105 | + |
| 106 | +It is currently in major version zero (``0.y.z``), which means that anything |
| 107 | +may change at any time and the public API should not be considered |
| 108 | +stable. |
| 109 | + |
| 110 | +Contributing |
| 111 | +------------ |
| 112 | + |
| 113 | +Contributions to this library are always welcome and highly encouraged. |
| 114 | + |
| 115 | +See `google-cloud`'s [CONTRIBUTING] documentation and the |
| 116 | +[shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) |
| 117 | +for more information on how to get started. |
| 118 | + |
| 119 | +Please note that this project is released with a Contributor Code of Conduct. |
| 120 | +By participating in this project you agree to abide by its terms. See |
| 121 | +[Code of Conduct][code-of-conduct] for more information. |
| 122 | + |
| 123 | +License |
| 124 | +------- |
| 125 | +Apache 2.0 - See [LICENSE] for more information. |
| 126 | + |
| 127 | + |
| 128 | +[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CONTRIBUTING.md |
| 129 | +[code-of-conduct]:https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct |
| 130 | +[LICENSE]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/LICENSE |
| 131 | +[TESTING]: https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-storage |
| 132 | +[cloud-platform]: https://cloud.google.com/ |
| 133 | + |
| 134 | +[cloud-logging]: https://cloud.google.com/logging/ |
| 135 | +[cloud-logging-docs]: https://cloud.google.com/logging/docs/overview |
0 commit comments