Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ See [Logback filters](https://logback.qos.ch/manual/filters.html#thresholdFilter
<!-- Optional: defaults to "java.log" -->
<log>application.log</log>

<!-- Optional: defaults to "ERROR" -->
<!-- Optional: defaults to "OFF" -->
<flushLevel>WARN</flushLevel>

<!-- Optional: defaults to ASYNC -->
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
Removing or replacing it should not affect the execution of the samples in any way.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* &lt;!-- Optional: defaults to {@code "java.log"} --&gt;
* &lt;log&gt;application.log&lt;/log&gt;
*
* &lt;!-- Optional: defaults to {@code "ERROR"} --&gt;
* &lt;!-- Optional: defaults to {@code "OFF"} --&gt;
* &lt;flushLevel&gt;WARN&lt;/flushLevel&gt;
*
* &lt;!-- Optional: defaults to {@code ASYNC} --&gt;
Expand Down Expand Up @@ -150,7 +150,7 @@ public class LoggingAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
/**
* Sets a threshold for log severity level to flush all log entries that were batched so far.
*
* <p>Defaults to Error.
* <p>Defaults to OFF.
*
* @param flushLevel Logback log level
*/
Expand Down Expand Up @@ -298,7 +298,7 @@ void setupMonitoredResource(MonitoredResource monitoredResource) {
}

private Level getFlushLevel() {
return (flushLevel != null) ? flushLevel : Level.ERROR;
return (flushLevel != null) ? flushLevel : Level.OFF;
}

private String getLogName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,15 @@ public void testFlushLevelConfigSupportsFlushLevelOff() {
assertThat(foundSeverity).isEqualTo(null);
}

@Test
public void testDefaultFlushLevelOff() {
loggingAppender.start();
Severity foundSeverity = logging.getFlushSeverity();
assertThat(foundSeverity).isEqualTo(null);
}

@Test
public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand Down Expand Up @@ -223,7 +229,6 @@ public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {

@Test
public void testPartialSuccessOverrideHasExpectedValue() {
logging.setFlushSeverity(Severity.ERROR);
Capture<WriteOption> logNameArg = Capture.newInstance();
Capture<WriteOption> resourceArg = Capture.newInstance();
Capture<WriteOption> partialSuccessArg = Capture.newInstance();
Expand All @@ -247,7 +252,6 @@ public void testPartialSuccessOverrideHasExpectedValue() {

@Test
public void testDefaultWriteOptionsHasExpectedDefaults() {
logging.setFlushSeverity(Severity.ERROR);
Capture<WriteOption> partialSuccessArg = Capture.newInstance();
logging.write(
EasyMock.<Iterable<LogEntry>>anyObject(),
Expand All @@ -266,7 +270,6 @@ public void testDefaultWriteOptionsHasExpectedDefaults() {

@Test
public void testMdcValuesAreConvertedToLabels() {
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand Down Expand Up @@ -325,7 +328,6 @@ public void testMdcValuesAreConvertedToLabelsWithPassingNullValues() {
MDC.put("mdc1", "value1");
MDC.put("mdc2", null);
MDC.put("mdc3", "value3");
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand All @@ -351,7 +353,6 @@ public void testMdcValuesAreConvertedToLabelsWithPassingNullValues() {
@Test
public void testAddCustomLoggingEventEnhancers() {
MDC.put("mdc1", "value1");
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand All @@ -375,7 +376,6 @@ public void testAddCustomLoggingEventEnhancers() {

@Test
public void testAddCustomLoggingEnhancer() {
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand All @@ -398,7 +398,6 @@ public void testAddCustomLoggingEnhancer() {
@Test
@SuppressWarnings("deprecation")
public void testFlush() {
logging.setFlushSeverity(Severity.ERROR);
logging.write(
EasyMock.<Iterable<LogEntry>>anyObject(),
anyObject(WriteOption.class),
Expand All @@ -419,7 +418,6 @@ public void testFlush() {

@Test
public void testAutoPopulationEnabled() {
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedLogEntries = Capture.newInstance();
EasyMock.expect(
logging.populateMetadata(
Expand Down Expand Up @@ -458,7 +456,6 @@ public void testAutoPopulationEnabled() {

@Test
public void testRedirectToStdoutEnabled() {
logging.setFlushSeverity(Severity.ERROR);
EasyMock.expect(
logging.populateMetadata(
EasyMock.<Iterable<LogEntry>>anyObject(),
Expand Down Expand Up @@ -503,7 +500,6 @@ public void testRedirectToStdoutDisabled() {
public void testFDiagnosticInfoAdded() {
LoggingAppender.setInstrumentationStatus(false);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.setFlushSeverity(Severity.ERROR);
logging.write(
capture(capturedArgument),
anyObject(WriteOption.class),
Expand Down Expand Up @@ -547,7 +543,6 @@ public void testFDiagnosticInfoAdded() {

@Test
public void testFDiagnosticInfoNotAdded() {
logging.setFlushSeverity(Severity.ERROR);
Capture<Iterable<LogEntry>> capturedArgument = Capture.newInstance();
logging.write(
capture(capturedArgument),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Optional: defaults to "java.log" -->
<log>application.log</log>

<!-- Optional: defaults to "ERROR" -->
<!-- Optional: defaults to "OFF" -->
<flushLevel>WARN</flushLevel>

<!-- Optional: defaults to ASYNC -->
Expand Down