You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ce...@apache.org on 2004/04/20 19:19:51 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j Hierarchy.java PropertyConfigurator.java
ceki 2004/04/20 10:19:51
Modified: docs HISTORY
src/java/org/apache/log4j/spi LoggerRepository.java
src/java/org/apache/log4j Hierarchy.java
PropertyConfigurator.java
Log:
- Added the "isPristine" falg to LoggerRepository. As soon as a configurator
starts configuring a repository this flag is set to false.
Revision Changes Path
1.105 +3 -0 logging-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/logging-log4j/docs/HISTORY,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- HISTORY 20 Apr 2004 10:02:31 -0000 1.104
+++ HISTORY 20 Apr 2004 17:19:51 -0000 1.105
@@ -11,6 +11,9 @@
April, 2004
+ - Added the "isPristine" falg to LoggerRepository. As soon as a configurator
+ starts configuring a repository this flag is set to false.
+
- Removed support for the deprecated property "log4j.configDebug". [**/D]
- Added keys() method to the MDC class as requested by Don Isenor.
1.15 +15 -0 logging-log4j/src/java/org/apache/log4j/spi/LoggerRepository.java
Index: LoggerRepository.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/spi/LoggerRepository.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- LoggerRepository.java 27 Feb 2004 16:47:34 -0000 1.14
+++ LoggerRepository.java 20 Apr 2004 17:19:51 -0000 1.15
@@ -104,6 +104,21 @@
public Logger getRootLogger();
+ /**
+ * Is the current configuration of the reposiroty, the original (pristine)
+ * configuration?
+ *
+ * @since 1.3
+ */
+ public boolean isPristine();
+
+ /**
+ * Set the pristine flag.
+ * @see #isPristine
+ * @since 1.3
+ */
+ public void setPristine(boolean state);
+
public abstract Logger exists(String name);
public abstract void shutdown();
1.49 +32 -13 logging-log4j/src/java/org/apache/log4j/Hierarchy.java
Index: Hierarchy.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Hierarchy.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- Hierarchy.java 27 Feb 2004 16:47:28 -0000 1.48
+++ Hierarchy.java 20 Apr 2004 17:19:51 -0000 1.49
@@ -1,12 +1,12 @@
/*
* Copyright 1999,2004 The Apache Software Foundation.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,6 +42,7 @@
// Anders Kristensen
// Igor Poteryaev
+
/**
This class is specialized in retrieving loggers by name and also
maintaining the logger hierarchy.
@@ -68,7 +69,6 @@
private LoggerFactory defaultFactory;
private ArrayList repositoryEventListeners;
private ArrayList loggerEventListeners;
-
String name;
Hashtable ht;
Logger root;
@@ -77,6 +77,7 @@
Level threshold;
boolean emittedNoAppenderWarning = false;
boolean emittedNoResourceBundleWarning = false;
+ boolean pristine = true;
/**
Create a new logger hierarchy.
@@ -211,22 +212,22 @@
return name;
}
- /*
+ /*
* Set the name of this repository.
- *
+ *
* Note that once named, a repository cannot be rerenamed.
* @since 1.3
*/
public void setName(String repoName) {
- if(name == null) {
+ if (name == null) {
name = repoName;
- } else if(!name.equals(repoName)) {
- throw new IllegalStateException("Repository ["+name
- +"] cannot be renamed as ["+repoName+"].");
+ } else if (!name.equals(repoName)) {
+ throw new IllegalStateException(
+ "Repository [" + name + "] cannot be renamed as [" + repoName + "].");
}
}
-
+
/**
The string form of {@link #setThreshold(Level)}.
*/
@@ -349,6 +350,7 @@
// return thresholdInt;
//}
+
/**
Return a new logger instance named as the first parameter using
the default factory.
@@ -381,6 +383,7 @@
//System.out.println("getInstance("+name+") called.");
CategoryKey key = new CategoryKey(name);
+
// Synchronize to prevent write conflicts. Read conflicts (in
// getChainedLevel method) are possible only if variable
// assignments are non-atomic.
@@ -490,6 +493,7 @@
root.setResourceBundle(null);
setThreshold(Level.ALL);
+
// the synchronization is needed to prevent JDK 1.2.x hashtable
// surprises
synchronized (ht) {
@@ -524,6 +528,20 @@
rendererMap.put(renderedClass, renderer);
}
+ /*
+ * @see org.apache.log4j.spi.LoggerRepository#isPristine()
+ */
+ public boolean isPristine() {
+ return pristine;
+ }
+
+ /*
+ * @see org.apache.log4j.spi.LoggerRepository#setPristine()
+ */
+ public void setPristine(boolean state) {
+ pristine = state;
+ }
+
/**
Shutting down a hierarchy will <em>safely</em> close and remove
all appenders in all categories including the root logger.
@@ -577,7 +595,7 @@
c.removeAllAppenders();
}
}
-
+
// log4j self configure
IntializationUtil.log4jInternalConfiguration(this);
}
@@ -607,6 +625,7 @@
int length = name.length();
boolean parentFound = false;
+
//System.out.println("UpdateParents called for " + name);
// if name = "w.x.y.z", loop thourgh "w.x.y", "w.x" and "w", but not "w.x.y.z"
for (
@@ -667,6 +686,7 @@
for (int i = 0; i < last; i++) {
Logger l = (Logger) pn.elementAt(i);
+
//System.out.println("Updating child " +p.name);
// Unless this child already points to a correct (lower) parent,
// make cat.parent point to l.parent and l.parent to cat.
@@ -676,5 +696,4 @@
}
}
}
-
}
1.65 +9 -5 logging-log4j/src/java/org/apache/log4j/PropertyConfigurator.java
Index: PropertyConfigurator.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/PropertyConfigurator.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- PropertyConfigurator.java 20 Apr 2004 10:02:31 -0000 1.64
+++ PropertyConfigurator.java 20 Apr 2004 17:19:51 -0000 1.65
@@ -380,25 +380,29 @@
See {@link #doConfigure(String, LoggerRepository)} for the expected format.
*/
- public void doConfigure(Properties properties, LoggerRepository hierarchy) {
+ public void doConfigure(Properties properties, LoggerRepository repository) {
String value = properties.getProperty(LogLog.DEBUG_KEY);
if (value != null) {
LogLog.setInternalDebugging(OptionConverter.toBoolean(value, true));
}
+ // As soon as we start configuration process, the pristine flag is set to
+ // false.
+ repository.setPristine(false);
+
String thresholdStr =
OptionConverter.findAndSubst(THRESHOLD_PREFIX, properties);
if (thresholdStr != null) {
- hierarchy.setThreshold(OptionConverter.toLevel(thresholdStr, Level.ALL));
+ repository.setThreshold(OptionConverter.toLevel(thresholdStr, Level.ALL));
LogLog.debug(
- "Hierarchy threshold set to [" + hierarchy.getThreshold() + "].");
+ "Hierarchy threshold set to [" + repository.getThreshold() + "].");
}
- configureRootCategory(properties, hierarchy);
+ configureRootCategory(properties, repository);
configureLoggerFactory(properties);
- parseCatsAndRenderers(properties, hierarchy);
+ parseCatsAndRenderers(properties, repository);
LogLog.debug("Finished configuring.");
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org