Subclassing java.util.logging.Formatter doesn't work

后端 未结 5 826
自闭症患者
自闭症患者 2021-01-06 16:23

I am using java.util.logging for logging (I don\'t want to use log4j or anything else).

This is my complete private logging.properties:

         


        
5条回答
  •  孤街浪徒
    2021-01-06 16:49

    com.mycomp.myproj.LogFormatter is not in your system class path.

    LogManager will do the following call for loading your class:

    Formatter getFormatterProperty(String name, Formatter defaultValue) {
            String val = getProperty(name);
            try {
                if (val != null) {
                    Class clz = ClassLoader.getSystemClassLoader().loadClass(val);
                    return (Formatter) clz.newInstance();
                }
            } catch (Exception ex) {
                // We got one of a variety of exceptions in creating the
                // class or creating an instance.
                // Drop through.
            }
            // We got an exception.  Return the defaultValue.
            return defaultValue;
    }
    

    You need to make sure your class LogFormatter is in the system's class path.

提交回复
热议问题