WildFly Logging Subsystem Configuration: Difference between revisions
Jump to navigation
Jump to search
Line 54: | Line 54: | ||
=Periodic Rotating File Handler Configuration= | =Periodic Rotating File Handler Configuration= | ||
The rotation period is inferred based on the "suffix" value. The "suffix" is a string that can be parsed with [[ | The rotation period is inferred based on the "suffix" value. The "suffix" is a string that can be parsed with [[Java SimpleDateFormat|java.text.SimpleDateFormat]]. | ||
. | . | ||
Revision as of 23:15, 7 November 2016
Internal
Relevance
- EAP 6.4
Overview
<subsystem xmlns="urn:jboss:domain:logging:1.5"> <periodic-rotating-file-handler name="FILE" autoflush="true"> <formatter> <named-formatter name="PATTERN"/> </formatter> <file relative-to="jboss.server.log.dir" path="server.log"/> <suffix value=".yyyy-MM-dd"/> <append value="true"/> </periodic-rotating-file-handler> <logger category="com.arjuna"> <level name="WARN"/> </logger> <logger category="org.apache.tomcat.util.modeler"> <level name="WARN"/> </logger> <logger category="org.jboss.as.config"> <level name="DEBUG"/> </logger> <logger category="sun.rmi"> <level name="WARN"/> </logger> <logger category="jacorb"> <level name="WARN"/> </logger> <logger category="jacorb.config"> <level name="ERROR"/> </logger> <root-logger> <level name="INFO"/> <handlers> <handler name="FILE"/> </handlers> </root-logger> <formatter name="PATTERN"> <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> </formatter> </subsystem>
Periodic Rotating File Handler Configuration
The rotation period is inferred based on the "suffix" value. The "suffix" is a string that can be parsed with java.text.SimpleDateFormat. .
* Set the suffix string. The string is in a format which can be understood by {@link java.text.SimpleDateFormat}. * The period of the rotation is automatically calculated based on the suffix. * * @param suffix the suffix * @throws IllegalArgumentException if the suffix is not valid */ public void setSuffix(String suffix) throws IllegalArgumentException { final SimpleDateFormat format = new SimpleDateFormat(suffix); format.setTimeZone(timeZone); final int len = suffix.length(); Period period = Period.NEVER; for (int i = 0; i < len; i ++) { switch (suffix.charAt(i)) { case 'y': period = min(period, Period.YEAR); break; case 'M': period = min(period, Period.MONTH); break; case 'w': case 'W': period = min(period, Period.WEEK); break; case 'D': case 'd': case 'F': case 'E': period = min(period, Period.DAY); break; case 'a': period = min(period, Period.HALF_DAY); break; case 'H': case 'k': case 'K': case 'h': period = min(period, Period.HOUR); break; case 'm': period = min(period, Period.MINUTE); break; case '\: while (suffix.charAt(++i) != '\); break; case 's': case 'S': throw new IllegalArgumentException("Rotating by second or millisecond is not supported"); } } synchronized (outputLock) { this.format = format; this.period = period; final long now; final File file = getFile(); if (file != null && file.lastModified() > 0) { now = file.lastModified(); } else { now = System.currentTimeMillis(); } calcNextRollover(now); } }
<periodic-rotating-file-handler name="TEST" autoflush="true"> <level name="ALL"/> <file relative-to="jboss.server.log.dir" path="test.log"/> <suffix value=".yyyy-MM-dd"/> <append value="true"/> </periodic-rotating-file-handler>