-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9670 from jamezp/issue9259
If the rotate-on-boot is defined and there is a file-suffix use the PeriodicSizeRotatingFileHandler
- Loading branch information
Showing
6 changed files
with
88 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../src/main/resources/application-periodic-size-file-log-rotating-rotate-on-boot.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
quarkus.log.level=INFO | ||
quarkus.log.file.enable=true | ||
quarkus.log.file.level=INFO | ||
quarkus.log.file.format=%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n | ||
quarkus.log.file.rotation.file-suffix=.yyyy-MM-dd | ||
quarkus.log.file.rotation.rotate-on-boot=true | ||
quarkus.root.dsa-key-location=/DSAPublicKey.encoded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...loyment/src/test/java/io/quarkus/logging/PeriodicSizeRotatingLoggingRotateOnBootTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.logging; | ||
|
||
import static io.quarkus.logging.LoggingTestsHelper.getHandler; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.logging.Formatter; | ||
import java.util.logging.Handler; | ||
import java.util.logging.Level; | ||
|
||
import org.jboss.logmanager.formatters.PatternFormatter; | ||
import org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class PeriodicSizeRotatingLoggingRotateOnBootTest { | ||
|
||
private static final String FILE_NAME = PeriodicSizeRotatingLoggingRotateOnBootTest.class.getSimpleName() + ".log"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withConfigurationResource("application-periodic-size-file-log-rotating-rotate-on-boot.properties") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(LoggingTestsHelper.class) | ||
.addAsManifestResource("application.properties", "microprofile-config.properties")) | ||
.setLogFileName(FILE_NAME); | ||
|
||
@Test | ||
public void periodicSizeRotatingConfigurationTest() { | ||
Handler handler = getHandler(PeriodicSizeRotatingFileHandler.class); | ||
assertThat(handler.getLevel()).isEqualTo(Level.INFO); | ||
|
||
Formatter formatter = handler.getFormatter(); | ||
assertThat(formatter).isInstanceOf(PatternFormatter.class); | ||
PatternFormatter patternFormatter = (PatternFormatter) formatter; | ||
assertThat(patternFormatter.getPattern()).isEqualTo("%d{HH:mm:ss} %-5p [%c{2.}]] (%t) %s%e%n"); | ||
|
||
PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = (PeriodicSizeRotatingFileHandler) handler; | ||
assertThat(periodicSizeRotatingFileHandler.isRotateOnBoot()).isTrue(); | ||
} | ||
} |