/**
  * Instantiate an object given a class name. Check that the <code>className</code> is a subclass
  * of <code>superClass</code>. If that test fails or the object could not be instantiated, then
  * <code>defaultValue</code> is returned.
  *
  * @param className The fully qualified class name of the object to instantiate.
  * @param superClass The class to which the new object should belong.
  * @param defaultValue The object to return in case of non-fulfillment
  */
 public static Object instantiateByClassName(
     String className, Class superClass, Object defaultValue) {
   if (className != null) {
     try {
       Class classObj = Loader.loadClass(className);
       if (!superClass.isAssignableFrom(classObj)) {
         LogLog.error(
             "A \""
                 + className
                 + "\" object is not assignable to a \""
                 + superClass.getName()
                 + "\" variable.");
         LogLog.error("The class \"" + superClass.getName() + "\" was loaded by ");
         LogLog.error("[" + superClass.getClassLoader() + "] whereas object of type ");
         LogLog.error(
             "\"" + classObj.getName() + "\" was loaded by [" + classObj.getClassLoader() + "].");
         return defaultValue;
       }
       return classObj.newInstance();
     } catch (Exception e) {
       LogLog.error("Could not instantiate class [" + className + "].", e);
     }
   }
   return defaultValue;
 }
  public static long toFileSize(String value, long dEfault) {
    if (value == null) return dEfault;

    String s = value.trim().toUpperCase();
    long multiplier = 1;
    int index;

    if ((index = s.indexOf("KB")) != -1) {
      multiplier = 1024;
      s = s.substring(0, index);
    } else if ((index = s.indexOf("MB")) != -1) {
      multiplier = 1024 * 1024;
      s = s.substring(0, index);
    } else if ((index = s.indexOf("GB")) != -1) {
      multiplier = 1024 * 1024 * 1024;
      s = s.substring(0, index);
    }
    if (s != null) {
      try {
        return Long.valueOf(s).longValue() * multiplier;
      } catch (NumberFormatException e) {
        LogLog.error("[" + s + "] is not in proper int form.");
        LogLog.error("[" + value + "] not in expected format.", e);
      }
    }
    return dEfault;
  }
 /** The option is expected to be in decimal and positive. In case of error, zero is returned. */
 protected int extractPrecisionOption() {
   String opt = extractOption();
   int r = 0;
   if (opt != null) {
     try {
       r = Integer.parseInt(opt);
       if (r <= 0) {
         LogLog.error("Precision option (" + opt + ") isn't a positive integer.");
         r = 0;
       }
     } catch (NumberFormatException e) {
       LogLog.error("Category option \"" + opt + "\" not a decimal integer.", e);
     }
   }
   return r;
 }
 /**
  * Very similar to <code>System.getProperty</code> except that the {@link SecurityException} is
  * hidden.
  *
  * @param key The key to search for.
  * @param def The default value to return.
  * @return the string value of the system property, or the default value if there is no property
  *     with that key.
  * @since 1.1
  */
 public static String getSystemproperty(String key, String def) {
   try {
     return System.getProperty(key, def);
   } catch (Throwable e) { // MS-Java throws com.ms.security.SecurityExceptionEx
     LogLog.debug("Was not allowed to read system property \"" + key + "\".");
     return def;
   }
 }
  public SyslogWriter(String syslogHost) {
    this.syslogHost = syslogHost;

    try {
      this.address = InetAddress.getByName(syslogHost);
    } catch (UnknownHostException e) {
      LogLog.error("Could not find " + syslogHost + ". All logging will FAIL.", e);
    }

    try {
      this.ds = new DatagramSocket();
    } catch (SocketException e) {
      e.printStackTrace();
      LogLog.error(
          "Could not instantiate DatagramSocket to " + syslogHost + ". All logging will FAIL.", e);
    }
  }
  /**
   * Converts a standard or custom priority level to a Level object.
   *
   * <p>If <code>value</code> is of form "level#classname", then the specified class' toLevel method
   * is called to process the specified level string; if no '#' character is present, then the
   * default {@link org.apache.log4j.Level} class is used to process the level value.
   *
   * <p>As a special case, if the <code>value</code> parameter is equal to the string "NULL", then
   * the value <code>null</code> will be returned.
   *
   * <p>If any error occurs while converting the value to a level, the <code>defaultValue</code>
   * parameter, which may be <code>null</code>, is returned.
   *
   * <p>Case of <code>value</code> is insignificant for the level level, but is significant for the
   * class name part, if present.
   *
   * @since 1.1
   */
  public static Level toLevel(String value, Level defaultValue) {
    if (value == null) return defaultValue;

    value = value.trim();

    int hashIndex = value.indexOf('#');
    if (hashIndex == -1) {
      if ("NULL".equalsIgnoreCase(value)) {
        return null;
      } else {
        // no class name specified : use standard Level class
        return (Level) Level.toLevel(value, defaultValue);
      }
    }

    Level result = defaultValue;

    String clazz = value.substring(hashIndex + 1);
    String levelName = value.substring(0, hashIndex);

    // This is degenerate case but you never know.
    if ("NULL".equalsIgnoreCase(levelName)) {
      return null;
    }

    LogLog.debug("toLevel" + ":class=[" + clazz + "]" + ":pri=[" + levelName + "]");

    try {
      Class customLevel = Loader.loadClass(clazz);

      // get a ref to the specified class' static method
      // toLevel(String, org.apache.log4j.Level)
      Class[] paramTypes = new Class[] {String.class, org.apache.log4j.Level.class};
      java.lang.reflect.Method toLevelMethod = customLevel.getMethod("toLevel", paramTypes);

      // now call the toLevel method, passing level string + default
      Object[] params = new Object[] {levelName, defaultValue};
      Object o = toLevelMethod.invoke(null, params);

      result = (Level) o;
    } catch (ClassNotFoundException e) {
      LogLog.warn("custom level class [" + clazz + "] not found.");
    } catch (NoSuchMethodException e) {
      LogLog.warn(
          "custom level class ["
              + clazz
              + "]"
              + " does not have a constructor which takes one string parameter",
          e);
    } catch (java.lang.reflect.InvocationTargetException e) {
      LogLog.warn("custom level class [" + clazz + "]" + " could not be instantiated", e);
    } catch (ClassCastException e) {
      LogLog.warn("class [" + clazz + "] is not a subclass of org.apache.log4j.Level", e);
    } catch (IllegalAccessException e) {
      LogLog.warn("class [" + clazz + "] cannot be instantiated due to access restrictions", e);
    } catch (Exception e) {
      LogLog.warn("class [" + clazz + "], level [" + levelName + "] conversion failed.", e);
    }
    return result;
  }
 /*     */ protected int extractPrecisionOption() /*     */ {
   /* 113 */ String opt = extractOption();
   /* 114 */ int r = 0;
   /* 115 */ if (opt != null) {
     /*     */ try {
       /* 117 */ r = Integer.parseInt(opt);
       /* 118 */ if (r <= 0) {
         /* 119 */ LogLog.error("Precision option (" + opt + ") isn't a positive integer.");
         /*     */
         /* 121 */ r = 0;
         /*     */ }
       /*     */ }
     /*     */ catch (NumberFormatException e) {
       /* 125 */ LogLog.error("Category option \"" + opt + "\" not a decimal integer.", e);
       /*     */ }
     /*     */ }
   /* 128 */ return r;
   /*     */ }
 public String convert(LoggingEvent event) {
   date.setTime(event.timeStamp);
   String converted = null;
   try {
     converted = df.format(date);
   } catch (Exception ex) {
     LogLog.error("Error occured while converting date.", ex);
   }
   return converted;
 }
 /*     */ public String convert(LoggingEvent event) /*     */ {
   /* 441 */ this.date.setTime(event.timeStamp);
   /* 442 */ String converted = null;
   /*     */ try {
     /* 444 */ converted = this.df.format(this.date);
     /*     */ }
   /*     */ catch (Exception ex) {
     /* 447 */ LogLog.error("Error occured while converting date.", ex);
     /*     */ }
   /* 449 */ return converted;
   /*     */ }
  /**
   * Find the value corresponding to <code>key</code> in <code>props</code>. Then perform variable
   * substitution on the found value.
   */
  public static String findAndSubst(String key, Properties props) {
    String value = props.getProperty(key);
    if (value == null) return null;

    try {
      return substVars(value, props);
    } catch (IllegalArgumentException e) {
      LogLog.error("Bad option value [" + value + "].", e);
      return value;
    }
  }
  /**
   * Configure log4j given a URL.
   *
   * <p>The url must point to a file or resource which will be interpreted by a new instance of a
   * log4j configurator.
   *
   * <p>All configurations steps are taken on the <code>hierarchy</code> passed as a parameter.
   *
   * <p>
   *
   * @param url The location of the configuration file or resource.
   * @param clazz The classname, of the log4j configurator which will parse the file or resource at
   *     <code>url</code>. This must be a subclass of {@link Configurator}, or null. If this value
   *     is null then a default configurator of {@link PropertyConfigurator} is used, unless the
   *     filename pointed to by <code>url</code> ends in '.xml', in which case {@link
   *     org.apache.log4j.xml.DOMConfigurator} is used.
   * @param hierarchy The {@link org.apache.log4j.Hierarchy} to act on.
   * @since 1.1.4
   */
  public static void selectAndConfigure(URL url, String clazz, LoggerRepository hierarchy) {
    Configurator configurator = null;
    String filename = url.getFile();

    if (clazz == null && filename != null && filename.endsWith(".xml")) {
      clazz = "org.apache.log4j.xml.DOMConfigurator";
    }

    if (clazz != null) {
      LogLog.debug("Preferred configurator class: " + clazz);
      configurator = (Configurator) instantiateByClassName(clazz, Configurator.class, null);
      if (configurator == null) {
        LogLog.error("Could not instantiate configurator [" + clazz + "].");
        return;
      }
    } else {
      configurator = new PropertyConfigurator();
    }

    configurator.doConfigure(url, hierarchy);
  }
 public static int toInt(String value, int dEfault) {
   if (value != null) {
     String s = value.trim();
     try {
       return Integer.valueOf(s).intValue();
     } catch (NumberFormatException e) {
       LogLog.error("[" + s + "] is not in proper int form.");
       e.printStackTrace();
     }
   }
   return dEfault;
 }
  public static Object instantiateByKey(
      Properties props, String key, Class superClass, Object defaultValue) {

    // Get the value of the property in string form
    String className = findAndSubst(key, props);
    if (className == null) {
      LogLog.error("Could not find value for key " + key);
      return defaultValue;
    }
    // Trim className to avoid trailing spaces that cause problems.
    return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue);
  }
Exemple #14
0
  /**
   * This method will search for <code>resource</code> in different places. The search order is as
   * follows:
   *
   * <ol>
   *   <p>
   *   <li>Search for <code>resource</code> using the thread context class loader under Java2. If
   *       that fails, search for <code>resource</code> using the class loader that loaded this
   *       class (<code>Loader</code>). Under JDK 1.1, only the the class loader that loaded this
   *       class (<code>Loader</code>) is used.
   *       <p>
   *   <li>Try one last time with <code>ClassLoader.getSystemResource(resource)</code>, that is is
   *       using the system class loader in JDK 1.2 and virtual machine's built-in class loader in
   *       JDK 1.1.
   * </ol>
   */
  public static URL getResource(String resource) {
    ClassLoader classLoader = null;
    URL url = null;

    try {
      if (!java1) {
        classLoader = getTCL();
        if (classLoader != null) {
          LogLog.debug(
              "Trying to find [" + resource + "] using context classloader " + classLoader + ".");
          url = classLoader.getResource(resource);
          if (url != null) {
            return url;
          }
        }
      }

      // We could not find resource. Ler us now try with the
      // classloader that loaded this class.
      classLoader = Loader.class.getClassLoader();
      if (classLoader != null) {
        LogLog.debug("Trying to find [" + resource + "] using " + classLoader + " class loader.");
        url = classLoader.getResource(resource);
        if (url != null) {
          return url;
        }
      }
    } catch (Throwable t) {
      LogLog.warn(TSTR, t);
    }

    // Last ditch attempt: get the resource from the class path. It
    // may be the case that clazz was loaded by the Extentsion class
    // loader which the parent of the system class loader. Hence the
    // code below.
    LogLog.debug("Trying to find [" + resource + "] using ClassLoader.getSystemResource().");
    return ClassLoader.getSystemResource(resource);
  }
Exemple #15
0
 public SyslogWriter(String syslogHost) {
   syslogHost = syslogHost;
   if (syslogHost == null) {
     throw new NullPointerException("syslogHost");
   }
   String host = syslogHost;
   int urlPort = -1;
   if ((host.indexOf("[") != -1) || (host.indexOf(':') == host.lastIndexOf(':'))) {
     try {
       URL url = new URL("http://" + host);
       if (url.getHost() != null) {
         host = url.getHost();
         if ((host.startsWith("[")) && (host.charAt(host.length() - 1) == ']')) {
           host = host.substring(1, host.length() - 1);
         }
         urlPort = url.getPort();
       }
     } catch (MalformedURLException e) {
       LogLog.error("Malformed URL: will attempt to interpret as InetAddress.", e);
     }
   }
   if (urlPort == -1) {
     urlPort = 514;
   }
   this.port = urlPort;
   try {
     this.address = InetAddress.getByName(host);
   } catch (UnknownHostException e) {
     LogLog.error("Could not find " + host + ". All logging will FAIL.", e);
   }
   try {
     this.ds = new DatagramSocket();
   } catch (SocketException e) {
     e.printStackTrace();
     LogLog.error(
         "Could not instantiate DatagramSocket to " + host + ". All logging will FAIL.", e);
   }
 }
  protected void checkAndConfigure() {
    boolean fileExists;
    try {
      fileExists = file.exists();
    } catch (SecurityException e) {
      LogLog.warn("Was not allowed to read check file existance, file:[" + filename + "].");
      interrupted = true; // there is no point in continuing
      return;
    }

    if (fileExists) {
      long l = file.lastModified(); // this can also throw a SecurityException
      if (l > lastModif) { // however, if we reached this point this
        lastModif = l; // is very unlikely.
        doOnChange();
        warnedAlready = false;
      }
    } else {
      if (!warnedAlready) {
        LogLog.debug("[" + filename + "] does not exist.");
        warnedAlready = true;
      }
    }
  }
 void dump() {
   LogLog.debug("min=" + min + ", max=" + max + ", leftAlign=" + leftAlign);
 }
 /*     */ public PatternConverter parse() /*     */ {
   /* 134 */ this.i = 0;
   /* 135 */ while (this.i < this.patternLength) {
     /* 136 */ char c = this.pattern.charAt(this.i++);
     /* 137 */ switch (this.state)
     /*     */ {
         /*     */ case 0:
         /* 140 */ if (this.i == this.patternLength) {
           /* 141 */ this.currentLiteral.append(c);
           /*     */ }
         /* 144 */ else if (c == '%')
         /*     */ {
           /* 146 */ switch (this.pattern.charAt(this.i)) {
               /*     */ case '%':
               /* 148 */ this.currentLiteral.append(c);
               /* 149 */ this.i += 1;
               /* 150 */ break;
               /*     */ case 'n':
               /* 152 */ this.currentLiteral.append(Layout.LINE_SEP);
               /* 153 */ this.i += 1;
               /* 154 */ break;
               /*     */ default:
               /* 156 */ if (this.currentLiteral.length() != 0) {
                 /* 157 */ addToList(new LiteralPatternConverter(this.currentLiteral.toString()));
                 /*     */ }
               /*     */
               /* 162 */ this.currentLiteral.setLength(0);
               /* 163 */ this.currentLiteral.append(c);
               /* 164 */ this.state = 1;
               /* 165 */ this.formattingInfo.reset();
               break;
               /*     */ }
           /*     */ }
         /*     */ else {
           /* 169 */ this.currentLiteral.append(c);
           /*     */ }
         /* 171 */ break;
         /*     */ case 1:
         /* 173 */ this.currentLiteral.append(c);
         /* 174 */ switch (c) {
             /*     */ case '-':
             /* 176 */ this.formattingInfo.leftAlign = true;
             /* 177 */ break;
             /*     */ case '.':
             /* 179 */ this.state = 3;
             /* 180 */ break;
             /*     */ default:
             /* 182 */ if ((c >= '0') && (c <= '9')) {
               /* 183 */ this.formattingInfo.min = (c - '0');
               /* 184 */ this.state = 4;
               /*     */ }
             /*     */ else {
               /* 187 */ finalizeConverter(c);
               /*     */ }
             /*     */ }
         /* 189 */ break;
         /*     */ case 4:
         /* 191 */ this.currentLiteral.append(c);
         /* 192 */ if ((c >= '0') && (c <= '9'))
           /* 193 */ this.formattingInfo.min = (this.formattingInfo.min * 10 + (c - '0'));
         /* 194 */ else if (c == '.') /* 195 */ this.state = 3;
         /*     */ else {
           /* 197 */ finalizeConverter(c);
           /*     */ }
         /* 199 */ break;
         /*     */ case 3:
         /* 201 */ this.currentLiteral.append(c);
         /* 202 */ if ((c >= '0') && (c <= '9')) {
           /* 203 */ this.formattingInfo.max = (c - '0');
           /* 204 */ this.state = 5;
           /*     */ }
         /*     */ else {
           /* 207 */ LogLog.error(
               "Error occured in position "
                   + this.i
                   + ".\n Was expecting digit, instead got char \""
                   + c
                   + "\".");
           /*     */
           /* 209 */ this.state = 0;
           /*     */ }
         /* 211 */ break;
         /*     */ case 5:
         /* 213 */ this.currentLiteral.append(c);
         /* 214 */ if ((c >= '0') && (c <= '9')) {
           /* 215 */ this.formattingInfo.max = (this.formattingInfo.max * 10 + (c - '0'));
           /*     */ } else {
           /* 217 */ finalizeConverter(c);
           /* 218 */ this.state = 0;
           /*     */ }
         /*     */ case 2:
         /*     */ }
     /*     */ }
   /* 223 */ if (this.currentLiteral.length() != 0) {
     /* 224 */ addToList(new LiteralPatternConverter(this.currentLiteral.toString()));
     /*     */ }
   /*     */
   /* 227 */ return this.head;
   /*     */ }
 public PatternConverter parse() {
   char c;
   i = 0;
   while (i < patternLength) {
     c = pattern.charAt(i++);
     switch (state) {
       case LITERAL_STATE:
         // In literal state, the last char is always a literal.
         if (i == patternLength) {
           currentLiteral.append(c);
           continue;
         }
         if (c == ESCAPE_CHAR) {
           // peek at the next char.
           switch (pattern.charAt(i)) {
             case ESCAPE_CHAR:
               currentLiteral.append(c);
               i++; // move pointer
               break;
             case 'n':
               currentLiteral.append(Layout.LINE_SEP);
               i++; // move pointer
               break;
             default:
               if (currentLiteral.length() != 0) {
                 addToList(new LiteralPatternConverter(currentLiteral.toString()));
                 // LogLog.debug("Parsed LITERAL converter: \""
                 //           +currentLiteral+"\".");
               }
               currentLiteral.setLength(0);
               currentLiteral.append(c); // append %
               state = CONVERTER_STATE;
               formattingInfo.reset();
           }
         } else {
           currentLiteral.append(c);
         }
         break;
       case CONVERTER_STATE:
         currentLiteral.append(c);
         switch (c) {
           case '-':
             formattingInfo.leftAlign = true;
             break;
           case '.':
             state = DOT_STATE;
             break;
           default:
             if (c >= '0' && c <= '9') {
               formattingInfo.min = c - '0';
               state = MIN_STATE;
             } else finalizeConverter(c);
         } // switch
         break;
       case MIN_STATE:
         currentLiteral.append(c);
         if (c >= '0' && c <= '9') formattingInfo.min = formattingInfo.min * 10 + (c - '0');
         else if (c == '.') state = DOT_STATE;
         else {
           finalizeConverter(c);
         }
         break;
       case DOT_STATE:
         currentLiteral.append(c);
         if (c >= '0' && c <= '9') {
           formattingInfo.max = c - '0';
           state = MAX_STATE;
         } else {
           LogLog.error(
               "Error occured in position "
                   + i
                   + ".\n Was expecting digit, instead got char \""
                   + c
                   + "\".");
           state = LITERAL_STATE;
         }
         break;
       case MAX_STATE:
         currentLiteral.append(c);
         if (c >= '0' && c <= '9') formattingInfo.max = formattingInfo.max * 10 + (c - '0');
         else {
           finalizeConverter(c);
           state = LITERAL_STATE;
         }
         break;
     } // switch
   } // while
   if (currentLiteral.length() != 0) {
     addToList(new LiteralPatternConverter(currentLiteral.toString()));
     // LogLog.debug("Parsed LITERAL converter: \""+currentLiteral+"\".");
   }
   return head;
 }
  protected void finalizeConverter(char c) {
    PatternConverter pc = null;
    switch (c) {
      case 'c':
        pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption());
        // LogLog.debug("CATEGORY converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'C':
        pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption());
        // LogLog.debug("CLASS_NAME converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'd':
        String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT;
        IDateFormat df;
        String dOpt = extractOption();
        if (dOpt != null) dateFormatStr = dOpt;

        if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT))
          df = new ISO8601DateFormat();
        else if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT))
          df = new AbsoluteTimeDateFormat();
        else if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT))
          df = new DateTimeDateFormat();
        else {
          try {
            df = new PatternDateFormat(dateFormatStr);
          } catch (IllegalArgumentException e) {
            LogLog.error("Could not instantiate SimpleDateFormat with " + dateFormatStr, e);
            df = new ISO8601DateFormat();
          }
        }
        pc = new DatePatternConverter(formattingInfo, df);
        // LogLog.debug("DATE converter {"+dateFormatStr+"}.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'F':
        pc = new LocationPatternConverter(formattingInfo, FILE_LOCATION_CONVERTER);
        // LogLog.debug("File name converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'l':
        pc = new LocationPatternConverter(formattingInfo, FULL_LOCATION_CONVERTER);
        // LogLog.debug("Location converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'L':
        pc = new LocationPatternConverter(formattingInfo, LINE_LOCATION_CONVERTER);
        // LogLog.debug("LINE NUMBER converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'm':
        pc = new BasicPatternConverter(formattingInfo, MESSAGE_CONVERTER);
        // LogLog.debug("MESSAGE converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'M':
        pc = new LocationPatternConverter(formattingInfo, METHOD_LOCATION_CONVERTER);
        // LogLog.debug("METHOD converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'p':
        pc = new BasicPatternConverter(formattingInfo, LEVEL_CONVERTER);
        // LogLog.debug("LEVEL converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 'r':
        pc = new BasicPatternConverter(formattingInfo, RELATIVE_TIME_CONVERTER);
        // LogLog.debug("RELATIVE time converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
      case 't':
        pc = new BasicPatternConverter(formattingInfo, THREAD_CONVERTER);
        // LogLog.debug("THREAD converter.");
        // formattingInfo.dump();
        currentLiteral.setLength(0);
        break;
        /*case 'u':
             if(i < patternLength) {
        char cNext = pattern.charAt(i);
        if(cNext >= '0' && cNext <= '9') {
          pc = new UserFieldPatternConverter(formattingInfo, cNext - '0');
          LogLog.debug("USER converter ["+cNext+"].");
          formattingInfo.dump();
          currentLiteral.setLength(0);
          i++;
        }
        else
          LogLog.error("Unexpected char" +cNext+" at position "+i);
             }
             break;*/
      case 'x':
        pc = new BasicPatternConverter(formattingInfo, NDC_CONVERTER);
        // LogLog.debug("NDC converter.");
        currentLiteral.setLength(0);
        break;
      case 'X':
        String xOpt = extractOption();
        pc = new MDCPatternConverter(formattingInfo, xOpt);
        currentLiteral.setLength(0);
        break;
      default:
        LogLog.error("Unexpected char [" + c + "] at position " + i + " in conversion patterrn.");
        pc = new LiteralPatternConverter(currentLiteral.toString());
        currentLiteral.setLength(0);
    }

    addConverter(pc);
  }
 /*     */ protected void finalizeConverter(char c) /*     */ {
   /* 232 */ PatternConverter pc = null;
   /* 233 */ switch (c) {
       /*     */ case 'c':
       /* 235 */ pc = new CategoryPatternConverter(this.formattingInfo, extractPrecisionOption());
       /*     */
       /* 239 */ this.currentLiteral.setLength(0);
       /* 240 */ break;
       /*     */ case 'C':
       /* 242 */ pc = new ClassNamePatternConverter(this.formattingInfo, extractPrecisionOption());
       /*     */
       /* 246 */ this.currentLiteral.setLength(0);
       /* 247 */ break;
       /*     */ case 'd':
       /* 249 */ String dateFormatStr = "ISO8601";
       /*     */
       /* 251 */ String dOpt = extractOption();
       /* 252 */ if (dOpt != null) /* 253 */ dateFormatStr = dOpt;
       /*     */ DateFormat df;
       /* 255 */ if (dateFormatStr.equalsIgnoreCase("ISO8601"))
       /*     */ {
         /* 257 */ df = new ISO8601DateFormat();
         /* 258 */ } else if (dateFormatStr.equalsIgnoreCase("ABSOLUTE"))
       /*     */ {
         /* 260 */ df = new AbsoluteTimeDateFormat();
         /* 261 */ } else if (dateFormatStr.equalsIgnoreCase("DATE"))
       /*     */ {
         /* 263 */ df = new DateTimeDateFormat();
         /*     */ }
       /*     */ else
         try {
           /* 266 */ df = new SimpleDateFormat(dateFormatStr);
           /*     */ }
         /*     */ catch (IllegalArgumentException e) {
           /* 269 */ LogLog.error(
               "Could not instantiate SimpleDateFormat with " + dateFormatStr, e);
           /*     */
           /* 271 */ df =
               (DateFormat)
                   OptionConverter.instantiateByClassName(
                       "org.apache.log4j.helpers.ISO8601DateFormat", DateFormat.class, null);
           /*     */ }
       /*     */
       /*     */
       /* 276 */ pc = new DatePatternConverter(this.formattingInfo, df);
       /*     */
       /* 279 */ this.currentLiteral.setLength(0);
       /* 280 */ break;
       /*     */ case 'F':
       /* 282 */ pc = new LocationPatternConverter(this.formattingInfo, 1004);
       /*     */
       /* 286 */ this.currentLiteral.setLength(0);
       /* 287 */ break;
       /*     */ case 'l':
       /* 289 */ pc = new LocationPatternConverter(this.formattingInfo, 1000);
       /*     */
       /* 293 */ this.currentLiteral.setLength(0);
       /* 294 */ break;
       /*     */ case 'L':
       /* 296 */ pc = new LocationPatternConverter(this.formattingInfo, 1003);
       /*     */
       /* 300 */ this.currentLiteral.setLength(0);
       /* 301 */ break;
       /*     */ case 'm':
       /* 303 */ pc = new BasicPatternConverter(this.formattingInfo, 2004);
       /*     */
       /* 306 */ this.currentLiteral.setLength(0);
       /* 307 */ break;
       /*     */ case 'M':
       /* 309 */ pc = new LocationPatternConverter(this.formattingInfo, 1001);
       /*     */
       /* 313 */ this.currentLiteral.setLength(0);
       /* 314 */ break;
       /*     */ case 'p':
       /* 316 */ pc = new BasicPatternConverter(this.formattingInfo, 2002);
       /*     */
       /* 319 */ this.currentLiteral.setLength(0);
       /* 320 */ break;
       /*     */ case 'r':
       /* 322 */ pc = new BasicPatternConverter(this.formattingInfo, 2000);
       /*     */
       /* 326 */ this.currentLiteral.setLength(0);
       /* 327 */ break;
       /*     */ case 't':
       /* 329 */ pc = new BasicPatternConverter(this.formattingInfo, 2001);
       /*     */
       /* 332 */ this.currentLiteral.setLength(0);
       /* 333 */ break;
       /*     */ case 'x':
       /* 349 */ pc = new BasicPatternConverter(this.formattingInfo, 2003);
       /*     */
       /* 351 */ this.currentLiteral.setLength(0);
       /* 352 */ break;
       /*     */ case 'X':
       /* 354 */ String xOpt = extractOption();
       /* 355 */ pc = new MDCPatternConverter(this.formattingInfo, xOpt);
       /* 356 */ this.currentLiteral.setLength(0);
       /* 357 */ break;
       /*     */ case 'D':
       /*     */ case 'E':
       /*     */ case 'G':
       /*     */ case 'H':
       /*     */ case 'I':
       /*     */ case 'J':
       /*     */ case 'K':
       /*     */ case 'N':
       /*     */ case 'O':
       /*     */ case 'P':
       /*     */ case 'Q':
       /*     */ case 'R':
       /*     */ case 'S':
       /*     */ case 'T':
       /*     */ case 'U':
       /*     */ case 'V':
       /*     */ case 'W':
       /*     */ case 'Y':
       /*     */ case 'Z':
       /*     */ case '[':
       /*     */ case '\\':
       /*     */ case ']':
       /*     */ case '^':
       /*     */ case '_':
       /*     */ case '`':
       /*     */ case 'a':
       /*     */ case 'b':
       /*     */ case 'e':
       /*     */ case 'f':
       /*     */ case 'g':
       /*     */ case 'h':
       /*     */ case 'i':
       /*     */ case 'j':
       /*     */ case 'k':
       /*     */ case 'n':
       /*     */ case 'o':
       /*     */ case 'q':
       /*     */ case 's':
       /*     */ case 'u':
       /*     */ case 'v':
       /*     */ case 'w':
       /*     */ default:
       /* 359 */ LogLog.error(
           "Unexpected char [" + c + "] at position " + this.i + " in conversion patterrn.");
       /*     */
       /* 361 */ pc = new LiteralPatternConverter(this.currentLiteral.toString());
       /* 362 */ this.currentLiteral.setLength(0);
       /*     */ }
   /*     */
   /* 365 */ addConverter(pc);
   /*     */ }