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 + 1log files.Based on
PeriodicSizeRotatingFileHandler.- Author:
- Jan Kalina, James R. Perkins, Yeray Borges
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSizeRotatingFileAuditEndpoint.BuilderA builder for size rotating file audit endpoints.
-
Field Summary
Fields Modifier and Type Field Description private longcurrentSizeprivate DateTimeFormatterdateTimeFormatterprivate intmaxBackupIndexprivate booleanrotateOnBootprivate longrotateSizeprivate Stringsuffix-
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.Builderbuilder()Obtain a newSizeRotatingFileAuditEndpoint.Buildercapable of building aSizeRotatingFileAuditEndpoint.protected voidpreWrite(Instant instant)Method called before writing into local file.private voidrotate(File file)Moves file to file.1, file.1 to file.2 etc.protected voidwrite(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 IOExceptionDescription copied from class:FileAuditEndpointMethod 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:
writein 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:FileAuditEndpointMethod 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:
preWritein 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.Buildercapable of building aSizeRotatingFileAuditEndpoint.- Returns:
- a new
SizeRotatingFileAuditEndpoint.Buildercapable of building aSizeRotatingFileAuditEndpoint.
-
-