WildFly Logging Subsystem Configuration: Difference between revisions

From NovaOrdis Knowledge Base
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 [[Java SimpleDateFormat|java.text.SimpleDateFormat]].  
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]]. The rotation period is the shortest identified amongst the following:
.


**
* yearly if the suffix string contains "y".
    * Set the suffix string.  The string is in a format which can be understood by {@link java.text.SimpleDateFormat}.
* monthly if the suffix string contains "M".
    * The period of the rotation is automatically calculated based on the suffix.
* weekly if the suffix contains "w" or "W".
    *
* daily if the suffix contains "D", "d" "F" or "E"
    * @param suffix the suffix
* half day if the suffix contains "a", "H", "k" or "K"
    * @throws IllegalArgumentException if the suffix is not valid
* hourly if the suffix contains "h"
    */
* every minute if the suffix contains "m"
    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);
        }
    }


Seconds and milliseconds are not supported.


<pre>
<pre>

Revision as of 23:20, 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. The rotation period is the shortest identified amongst the following:

  • yearly if the suffix string contains "y".
  • monthly if the suffix string contains "M".
  • weekly if the suffix contains "w" or "W".
  • daily if the suffix contains "D", "d" "F" or "E"
  • half day if the suffix contains "a", "H", "k" or "K"
  • hourly if the suffix contains "h"
  • every minute if the suffix contains "m"

Seconds and milliseconds are not supported.

<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>