Package org.wildfly.security.audit
Class SizeRotatingFileAuditEndpoint
- java.lang.Object
-
- org.wildfly.security.audit.FileAuditEndpoint
-
- org.wildfly.security.audit.SizeRotatingFileAuditEndpoint
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.wildfly.common.function.ExceptionBiConsumer<EventPriority,String,IOException>
,AuditEndpoint
public class SizeRotatingFileAuditEndpoint extends FileAuditEndpoint
An audit endpoint which rotates the log when log file size reach given value.Moves old log records into files tagged by index - the older has the higher index. When index reach
maxBackupIndex
, the oldest log file is removed, so there are at mostmaxBackupIndex + 1
log files.Based on
PeriodicSizeRotatingFileHandler
.- Author:
- Jan Kalina, James R. Perkins, Yeray Borges
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SizeRotatingFileAuditEndpoint.Builder
A builder for size rotating file audit endpoints.
-
Field Summary
Fields Modifier and Type Field Description private long
currentSize
private DateTimeFormatter
dateTimeFormatter
private int
maxBackupIndex
private boolean
rotateOnBoot
private long
rotateSize
private String
suffix
-
Fields inherited from class org.wildfly.security.audit.FileAuditEndpoint
clock
-
-
Constructor Summary
Constructors Constructor Description SizeRotatingFileAuditEndpoint(SizeRotatingFileAuditEndpoint.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SizeRotatingFileAuditEndpoint.Builder
builder()
Obtain a newSizeRotatingFileAuditEndpoint.Builder
capable of building aSizeRotatingFileAuditEndpoint
.protected void
preWrite(Instant instant)
Method called before writing into local file.private void
rotate(File file)
Moves file to file.1, file.1 to file.2 etc.protected void
write(byte[] bytes)
Method called to write given byte array to the target local file.-
Methods inherited from class org.wildfly.security.audit.FileAuditEndpoint
accept, close, closeStreams, getFile, setFile
-
-
-
-
Field Detail
-
rotateSize
private final long rotateSize
-
maxBackupIndex
private final int maxBackupIndex
-
rotateOnBoot
private final boolean rotateOnBoot
-
currentSize
private long currentSize
-
suffix
private final String suffix
-
dateTimeFormatter
private final DateTimeFormatter dateTimeFormatter
-
-
Constructor Detail
-
SizeRotatingFileAuditEndpoint
SizeRotatingFileAuditEndpoint(SizeRotatingFileAuditEndpoint.Builder builder) throws IOException
- Throws:
IOException
-
-
Method Detail
-
write
protected void write(byte[] bytes) throws IOException
Description copied from class:FileAuditEndpoint
Method called to write given byte array to the target local file. This method can be overridden by subclasses to modify data written into file (to encrypt them for example), or just for counting amount of written bytes for needs of log rotation and similar. This method can be invoked only in synchronization block surrounding one log message processing.- Overrides:
write
in classFileAuditEndpoint
- Parameters:
bytes
- the data to be written into the target local file- Throws:
IOException
-
preWrite
protected void preWrite(Instant instant)
Description copied from class:FileAuditEndpoint
Method called before writing into local file. This method is NO-OP by default. It is intended to be overridden by subclasses which need to perform some operation before every writing into the target local file. This method can be invoked only in synchronization block surrounding one log message processing.- Overrides:
preWrite
in classFileAuditEndpoint
- Parameters:
instant
- time of the message acceptance
-
rotate
private void rotate(File file) throws IOException
Moves file to file.1, file.1 to file.2 etc. Removes file.{maxBackupIndex}- Throws:
IOException
-
builder
public static SizeRotatingFileAuditEndpoint.Builder builder()
Obtain a newSizeRotatingFileAuditEndpoint.Builder
capable of building aSizeRotatingFileAuditEndpoint
.- Returns:
- a new
SizeRotatingFileAuditEndpoint.Builder
capable of building aSizeRotatingFileAuditEndpoint
.
-
-