Skip to content

Commit

Permalink
Logging - set default value for quarkus.log.file.rotation.max-file-size
Browse files Browse the repository at this point in the history
- also change the default value for
quarkus.log.file.rotation.max-backup-index
  • Loading branch information
mkouba committed Apr 21, 2022
1 parent 09897d1 commit 339ced5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public static class RotationConfig {
/**
* The maximum file size of the log file after which a rotation is executed.
*/
@ConfigItem(defaultValueDocumentation = "10")
Optional<MemorySize> maxFileSize;
@ConfigItem(defaultValue = "10M")
MemorySize maxFileSize;

/**
* The maximum number of backups to keep.
*/
@ConfigItem(defaultValue = "1")
@ConfigItem(defaultValue = "5")
int maxBackupIndex;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.jboss.logmanager.handlers.AsyncHandler;
import org.jboss.logmanager.handlers.ConsoleHandler;
import org.jboss.logmanager.handlers.FileHandler;
import org.jboss.logmanager.handlers.PeriodicRotatingFileHandler;
import org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler;
import org.jboss.logmanager.handlers.SizeRotatingFileHandler;
import org.jboss.logmanager.handlers.SyslogHandler;
Expand Down Expand Up @@ -470,26 +469,20 @@ public void close() throws SecurityException {

private static Handler configureFileHandler(final FileConfig config, final ErrorManager errorManager,
final LogCleanupFilter cleanupFilter) {
FileHandler handler = new FileHandler();
FileHandler handler;
FileConfig.RotationConfig rotationConfig = config.rotation;
if ((rotationConfig.maxFileSize.isPresent() || rotationConfig.rotateOnBoot)
&& rotationConfig.fileSuffix.isPresent()) {
if (rotationConfig.fileSuffix.isPresent()) {
PeriodicSizeRotatingFileHandler periodicSizeRotatingFileHandler = new PeriodicSizeRotatingFileHandler();
periodicSizeRotatingFileHandler.setSuffix(rotationConfig.fileSuffix.get());
rotationConfig.maxFileSize
.ifPresent(memorySize -> periodicSizeRotatingFileHandler.setRotateSize(memorySize.asLongValue()));
periodicSizeRotatingFileHandler.setRotateSize(rotationConfig.maxFileSize.asLongValue());
periodicSizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot);
periodicSizeRotatingFileHandler.setMaxBackupIndex(rotationConfig.maxBackupIndex);
handler = periodicSizeRotatingFileHandler;
} else if (rotationConfig.maxFileSize.isPresent()) {
} else {
SizeRotatingFileHandler sizeRotatingFileHandler = new SizeRotatingFileHandler(
rotationConfig.maxFileSize.get().asLongValue(), rotationConfig.maxBackupIndex);
rotationConfig.maxFileSize.asLongValue(), rotationConfig.maxBackupIndex);
sizeRotatingFileHandler.setRotateOnBoot(rotationConfig.rotateOnBoot);
handler = sizeRotatingFileHandler;
} else if (rotationConfig.fileSuffix.isPresent()) {
PeriodicRotatingFileHandler periodicRotatingFileHandler = new PeriodicRotatingFileHandler();
periodicRotatingFileHandler.setSuffix(rotationConfig.fileSuffix.get());
handler = periodicRotatingFileHandler;
}

final PatternFormatter formatter = new PatternFormatter(config.format);
Expand Down

0 comments on commit 339ced5

Please sign in to comment.