Methods Summary |
---|
public static java.lang.String | capitalize(java.lang.String name)
if (Character.isLowerCase(name.charAt(0))) {
if (name.length() == 1 || Character.isLowerCase(name.charAt(1))) {
StringBuffer newname = new StringBuffer(name);
newname.setCharAt(0, Character.toUpperCase(name.charAt(0)));
return newname.toString();
}
}
return name;
|
public void | foundProperty(java.lang.Object obj, java.lang.String prefix, java.lang.String name, java.lang.Object value)
// XXX: Properties encode value.toString()
if (obj instanceof Appender && "name".equals(name)) {
return;
}
if (doCapitalize) {
name = capitalize(name);
}
out.println(prefix + name + "=" + value.toString());
|
protected java.lang.String | genAppName()
return "A" + numAppenders++;
|
protected boolean | isGenAppName(java.lang.String name)Returns true if the specified appender name is considered to have
been generated, that is, if it is of the form A[0-9]+.
if (name.length() < 2 || name.charAt(0) != 'A") return false;
for (int i = 0; i < name.length(); i++) {
if (name.charAt(i) < '0" || name.charAt(i) > '9") return false;
}
return true;
|
public static void | main(java.lang.String[] args)
new PropertyPrinter(new PrintWriter(System.out));
|
public void | print(java.io.PrintWriter out)Prints the configuration of the default log4j hierarchy as a Java
properties file on the specified Writer.
N.B. print() can be invoked only once!
printOptions(out, Logger.getRootLogger());
Enumeration cats = LogManager.getCurrentLoggers();
while (cats.hasMoreElements()) {
printOptions(out, (Logger) cats.nextElement());
}
|
protected void | printOptions(java.io.PrintWriter out, org.apache.log4j.Category cat)
Enumeration appenders = cat.getAllAppenders();
Level prio = cat.getLevel();
String appenderString = (prio == null ? "" : prio.toString());
while (appenders.hasMoreElements()) {
Appender app = (Appender) appenders.nextElement();
String name;
if ((name = (String) appenderNames.get(app)) == null) {
// first assign name to the appender
if ((name = app.getName()) == null || isGenAppName(name)) {
name = genAppName();
}
appenderNames.put(app, name);
printOptions(out, app, "log4j.appender."+name);
if (app.getLayout() != null) {
printOptions(out, app.getLayout(), "log4j.appender."+name+".layout");
}
}
appenderString += ", " + name;
}
String catKey = (cat == Logger.getRootLogger())
? "log4j.rootLogger"
: "log4j.logger." + cat.getName();
if (appenderString != "") {
out.println(catKey + "=" + appenderString);
}
if (!cat.getAdditivity() && cat != Logger.getRootLogger()) {
out.println("log4j.additivity." + cat.getName() + "=false");
}
|
protected void | printOptions(java.io.PrintWriter out, org.apache.log4j.Logger cat)
printOptions(out, (Category) cat);
|
protected void | printOptions(java.io.PrintWriter out, java.lang.Object obj, java.lang.String fullname)
out.println(fullname + "=" + obj.getClass().getName());
PropertyGetter.getProperties(obj, this, fullname + ".");
|