java - How does Wildfly know that a number of files need to be deleted if the "max-backup-index" attribute has been configured? -


in order implement this issue, i.e., max-backup-index feature periodic-rotating-file-handler trying understand how max-backup-index attribute works in size-rotating-file-handler.

attempts

wildfly reads xml configuration:

<size-rotating-file-handler name="file" autoflush="true">     <level name="info"/>     <formatter>         <pattern-formatter pattern="%d{hh:mm:ss,sss} %-5p [%c] (%t) %s%e%n"/>     </formatter>     <file relative-to="jboss.server.log.dir" path="server.log"/>     <rotate-size value="100k"/>     <max-backup-index value="10"/>     <append value="true"/> </size-rotating-file-handler> 

if number of log files greater 10, wildfly remove files until 10 left.

the wildfly code resides on github has been viewed in order understand code responsible reading <max-backup-index value="10"/> snippet , removing superfluous log files.

periodicsizerotatinghandlerresourcedefinition

class periodicsizerotatinghandlerresourcedefinition extends abstractfilehandlerdefinition {      public static final string periodic_size_rotating_file_handler = "periodic-size-rotating-file-handler";     static final pathelement periodic_size_rotating_handler_path = pathelement.pathelement(periodic_size_rotating_file_handler);          static final attributedefinition[] attributes = logging.join(default_attributes, autoflush, append, max_backup_index, rotate_size, rotate_on_boot, suffix, named_formatter, file);      public periodicsizerotatinghandlerresourcedefinition(final resolvepathhandler resolvepathhandler) {         super(periodic_size_rotating_handler_path, false, periodicsizerotatingfilehandler.class, resolvepathhandler, attributes);     } 

super refers constructor of superclass, i.e, abstractfilehandlerdefinition

abstract class abstractfilehandlerdefinition extends abstracthandlerdefinition {     protected abstractfilehandlerdefinition(final pathelement path, final boolean registerlegacyops,                                             final class<? extends handler> type,                                             final resolvepathhandler resolvepathhandler,                                             final attributedefinition... attributes) {         super(path, registerlegacyops, type, new defaultpropertysorter(filenamelastcomparator.instance), attributes);         this.registerlegacyops = registerlegacyops;         this.resolvepathhandler = resolvepathhandler;     } 

super refers abstracthandlerdefinition

abstract class abstracthandlerdefinition extends transformerresourcedefinition {      protected abstracthandlerdefinition(final pathelement path,                                         final boolean registerlegacyops,                                         final class<? extends handler> type,                                         final propertysorter propertysorter,                                         final attributedefinition[] attributes) {         this(path, registerlegacyops, type, propertysorter, attributes, null, attributes);     } 

current outcome

at moment feels lost in labyrinth. cannot find code explains interaction between max-backup-index attribute , size-rotating-file-handler.

you need @ jboss log manager not wildfly. wildfly delegates log manager. you're looking this.

that said tricky issue. there's not reliable way determine files should deleted. date suffix can best guess isn't great. don't want log rotation delete files you're intentionally trying save.

for example have server.log.2015-01-01 , server.log.2015-01-01.save. how know delete first one? don't want delete second potentially got renamed user.

there's performance consider. don't want block while complex file matching algorithm run. default logging blocking code trying log blocked until rotation complete.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -