Skip to content

Conversation

@jabubake
Copy link
Contributor

@jabubake jabubake commented May 9, 2017

Adding logback support (via Slf4j surface) for google-cloud-logging

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 9, 2017
@jabubake
Copy link
Contributor Author

jabubake commented May 9, 2017

@meltsufin , @gregw PTAL

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 46dc384 on jabubake:cloud-logging-logback-adapter into ** on GoogleCloudPlatform:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 0184291 on jabubake:cloud-logging-logback-adapter into ** on GoogleCloudPlatform:master**.

<appender name="CLOUD" class="com.google.cloud.logging.contrib.LoggingAppender">
<level>DEBUG</level> <!-- Optional : default INFO -->
<log>application.log</log> <!-- Optional : default java.log -->
<enhancers>com.google.cloud.logging.TestLoggingEnhancer</enhancers> <!-- Optional -->

This comment was marked as spam.

This comment was marked as spam.

Add the appender to your [Logback configuration](https://logback.qos.ch/manual/configuration.html) `logback.xml`
```xml
<configuration>
<appender name="CLOUD" class="com.google.cloud.logging.contrib.LoggingAppender">

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

return MonitoredResourceUtil.getResource(projectId, resourceType);
}

List<LoggingEnhancer> getEnhancers() {

This comment was marked as spam.

This comment was marked as spam.

Copy link
Member

@meltsufin meltsufin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jisha for putting this together!

}

/**
* Sets the minimum logging level, defaults to INFO

This comment was marked as spam.

This comment was marked as spam.

List<LoggingEnhancer> enhancers = new ArrayList<>();
if (list != null) {
String[] items = list.split(",");
for (String e_name : items) {

This comment was marked as spam.

This comment was marked as spam.

/**
* Add extra labels using classes that implement {@link LoggingEnhancer}.
*
* @param enhancers list of enhancer classnames

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 4348833 on jabubake:cloud-logging-logback-adapter into ** on GoogleCloudPlatform:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8cd6b19 on jabubake:cloud-logging-logback-adapter into ** on GoogleCloudPlatform:master**.

@jabubake
Copy link
Contributor Author

@garrettjonesgoogle PTAL

private String enhancers;

/**
* Batched logging requests get immediately flushed for logs at or above level.

This comment was marked as spam.

This comment was marked as spam.

}

/**
* Sets the log filename, defaults to java.log.

This comment was marked as spam.

This comment was marked as spam.

* Sets the name of the monitored resource (Optional).
*
* <p>Must be a <a href="https://cloud.google.com/logging/docs/api/v2/resource-list">supported</a>
* resource type. gae_app, gce_instance and container are auto-detected, defaults to "global"

This comment was marked as spam.

This comment was marked as spam.

* <p>Must be a <a href="https://cloud.google.com/logging/docs/api/v2/resource-list">supported</a>
* resource type. gae_app, gce_instance and container are auto-detected, defaults to "global"
*
* @param resourceType name of monitored resource

This comment was marked as spam.

This comment was marked as spam.

*
* @param enhancers list of enhancer classnames (comma separated)
*/
public void setEnhancers(String enhancers) {

This comment was marked as spam.

This comment was marked as spam.

<!-- Optional : filter logs at or above a level -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>

This comment was marked as spam.

This comment was marked as spam.

-----------

This library is usable, but not yet complete.
* Auto-reload of properties is not fully tested

This comment was marked as spam.

This comment was marked as spam.

super.stop();
}

protected Logging getLogging() {

This comment was marked as spam.

This comment was marked as spam.

super.start();
}

protected String getProjectId() {

This comment was marked as spam.

This comment was marked as spam.


/** Initialze and configure the cloud logging service. */
@Override
public synchronized void start() {

This comment was marked as spam.

This comment was marked as spam.

jabubake added 2 commits May 16, 2017 09:15
enhancers now individual xml elements
code cleanup based on review
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 667a4d0 on jabubake:cloud-logging-logback-adapter into ** on GoogleCloudPlatform:master**.

@garrettjonesgoogle
Copy link
Member

Everything looks good, except the versions need to be updated again - s/0.17.2/0.18.0/ and s/0.17.3-alpha-SNAPSHOT/0.18.1-alpha/SNAPSHOT/

@jabubake
Copy link
Contributor Author

@garrettjonesgoogle done.

@garrettjonesgoogle
Copy link
Member

LGTM

@jabubake jabubake merged commit ad54a73 into googleapis:master May 23, 2017
@jabubake jabubake deleted the cloud-logging-logback-adapter branch May 23, 2017 19:01
meltsufin pushed a commit that referenced this pull request Dec 22, 2025
 Logback support for google-cloud-logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants