cvs commit: jakarta-log4j/src/xdocs/lf5 examples.xml faq.xml trouble.xml
[email protected] 19 Jun 2002 10:01:06 -0000
| Newsgroups | gmane.comp.jakarta.log4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
ceki 2002/06/19 03:01:05
Modified: . Tag: v1_2-branch build.xml
docs Tag: v1_2-branch HISTORY
src/java/org/apache/log4j Tag: v1_2-branch
DailyRollingFileAppender.java
src/java/org/apache/log4j/net Tag: v1_2-branch
SimpleSocketServer.java SocketNode.java
src/xdocs/lf5 Tag: v1_2-branch examples.xml faq.xml
trouble.xml
Log:
Minor documentation changes or improvements.
Indentation changes.
SimpleSocketServer now takes XML configuration files in addition to files in properties format.
Revision Changes Path
No revision
No revision
1.34.2.7 +7 -3 jakarta-log4j/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-log4j/build.xml,v
retrieving revision 1.34.2.6
retrieving revision 1.34.2.7
diff -u -r1.34.2.6 -r1.34.2.7
--- build.xml 12 Jun 2002 21:31:33 -0000 1.34.2.6
+++ build.xml 19 Jun 2002 10:01:02 -0000 1.34.2.7
@@ -17,7 +17,7 @@
<!-- prefixed with "env". -->
<property environment="env"/>
- <property name="version" value="1.2.4"/>
+ <property name="version" value="1.2.5"/>
<!-- The base directory relative to which most targets are built -->
<property name="base" value="."/>
@@ -191,7 +191,7 @@
<copy todir="${javac.dest}">
<fileset dir="${java.source.dir}"
- includes="${stem}/lf5/**/*.properties"/>
+ includes="${stem}/lf5/**/*.properties"/>
<fileset dir="${java.source.dir}"
includes="${stem}/lf5/viewer/images/*"/>
</copy>
@@ -213,6 +213,7 @@
<copy todir="${javac.dest}">
<fileset dir="." includes="examples/lf5/**/*.properties"/>
+ <fileset dir="." includes="examples/lf5/**/*.xml"/>
</copy>
</target>
@@ -330,6 +331,9 @@
${stem}/jdbc/*.class,
${stem}/varia/*.class,
${stem}/chainsaw/*.class,
+ ${stem}/lf5/**/*.class,
+ ${stem}/lf5/**/*.properties,
+ ${stem}/lf5/**/*.gif,
${stem}/nt/*.class,
${stem}/xml/*.class,
${stem}/jmx/*.class,
@@ -491,7 +495,7 @@
**/*.bak, **/goEnv.bat,
**/Makefile, **/goEnv.bat,
docs/pub-support/*,
- dist/classes/org/**,
+ dist/classes/org/**,
src/java/org/apache/log4j/test/**/*,
**/.#*"/>
</copy>
No revision
No revision
1.97.2.8 +4 -1 jakarta-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
retrieving revision 1.97.2.7
retrieving revision 1.97.2.8
diff -u -r1.97.2.7 -r1.97.2.8
--- HISTORY 12 Jun 2002 21:31:34 -0000 1.97.2.7
+++ HISTORY 19 Jun 2002 10:01:03 -0000 1.97.2.8
@@ -9,11 +9,14 @@
- Release of version 1.2.4
+ - The JDBCAppender is marked as slated for replacement. Do not build
+ critical software using it.
+
- Added LF5 documentation and examples. Further tests are required
for full integration. [*]
- XMLLayout can now output messages which contain embedded CDATA
- sections. This resolves bug #9750. Many thanks Michael
+ sections. This resolves bug #9750. Many thanks to Michael
A. McAngus for supplying the relevant patch. [*]
- The dispatcher thread associated with AsyncAppender is now marked
No revision
No revision
1.20.2.3 +39 -41 jakarta-log4j/src/java/org/apache/log4j/DailyRollingFileAppender.java
Index: DailyRollingFileAppender.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/DailyRollingFileAppender.java,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -u -r1.20.2.2 -r1.20.2.3
--- DailyRollingFileAppender.java 13 Jun 2002 21:48:19 -0000 1.20.2.2
+++ DailyRollingFileAppender.java 19 Jun 2002 10:01:04 -0000 1.20.2.3
@@ -143,13 +143,19 @@
private String datePattern = "'.'yyyy-MM-dd";
/**
- The actual formatted filename that is currently being written to.
+ The log file will be renamed to the value of the
+ scheduledFilename variable when the next interval is entered. For
+ example, if the rollover period is one hour, the log file will be
+ renamed to the value of "scheduledFilename" at the beginning of
+ the next hour.
+
+ The precise time when a rollover occurs depends on logging
+ activity.
*/
private String scheduledFilename;
/**
- The timestamp when we shall next recompute the filename.
- */
+ The next time we estimate a rollover should occur. */
private long nextCheck = System.currentTimeMillis () - 1;
Date now = new Date();
@@ -160,14 +166,13 @@
int checkPeriod = TOP_OF_TROUBLE;
-
+ // The gmtTimeZone is used only in computeCheckPeriod() method.
static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
/**
The default constructor does nothing. */
- public
- DailyRollingFileAppender() {
+ public DailyRollingFileAppender() {
}
/**
@@ -188,19 +193,16 @@
expected by {@link SimpleDateFormat}. This options determines the
rollover schedule.
*/
- public
- void setDatePattern(String pattern) {
+ public void setDatePattern(String pattern) {
datePattern = pattern;
}
/** Returns the value of the <b>DatePattern</b> option. */
- public
- String getDatePattern() {
+ public String getDatePattern() {
return datePattern;
}
- public
- void activateOptions() {
+ public void activateOptions() {
super.activateOptions();
if(datePattern != null && fileName != null) {
now.setTime(System.currentTimeMillis());
@@ -212,8 +214,8 @@
scheduledFilename = fileName+sdf.format(new Date(file.lastModified()));
} else {
- LogLog.error("Either Filename or DatePattern options are not set for ["+
- name+"].");
+ LogLog.error("Either File or DatePattern options are not set for appender ["
+ +name+"].");
}
}
@@ -290,6 +292,9 @@
}
String datedFilename = fileName+sdf.format(now);
+ // It is too early to roll over because we are still within the
+ // bounds of the current interval. Rollover will occur once the
+ // next interval is reached.
if (scheduledFilename.equals(datedFilename)) {
return;
}
@@ -303,8 +308,12 @@
}
File file = new File(fileName);
- file.renameTo(target);
- LogLog.debug(fileName +" -> "+ scheduledFilename);
+ boolean result = file.renameTo(target);
+ if(result) {
+ LogLog.debug(fileName +" -> "+ scheduledFilename);
+ } else {
+ LogLog.error("Failed to rename ["+fileName+"] to ["+scheduledFilename+"].");
+ }
try {
// This will also close the file. This is OK since multiple
@@ -318,17 +327,14 @@
}
/**
- This method differentiates DailyRollingFileAppender from its
- super class.
-
- <p>Before actually logging, this method will check whether it is
- time to do a rollover. If it is, it will schedule the next
- rollover time and then rollover.
-
-
- */
- protected
- void subAppend(LoggingEvent event) {
+ * This method differentiates DailyRollingFileAppender from its
+ * super class.
+ *
+ * <p>Before actually logging, this method will check whether it is
+ * time to do a rollover. If it is, it will schedule the next
+ * rollover time and then rollover.
+ * */
+ protected void subAppend(LoggingEvent event) {
long n = System.currentTimeMillis();
if (n >= nextCheck) {
now.setTime(n);
@@ -345,16 +351,10 @@
}
/**
- RollingCalendar is a helper class to
- DailyRollingFileAppender. Using this class, it is easy to compute
- and access the next Millis().
-
- It subclasses the standard {@link GregorianCalendar}-object, to
- allow access to the protected function getTimeInMillis(), which it
- then exports.
-
- @author <a HREF="mailto:[email protected]">Eirik Lygre</a> */
-
+ * RollingCalendar is a helper class to DailyRollingFileAppender.
+ * Given a periodicity type and the current time, it computes the
+ * start of the next interval.
+ * */
class RollingCalendar extends GregorianCalendar {
int type = DailyRollingFileAppender.TOP_OF_TROUBLE;
@@ -371,13 +371,11 @@
this.type = type;
}
- public
- long getNextCheckMillis(Date now) {
+ public long getNextCheckMillis(Date now) {
return getNextCheckDate(now).getTime();
}
- public
- Date getNextCheckDate(Date now) {
+ public Date getNextCheckDate(Date now) {
this.setTime(now);
switch(type) {
No revision
No revision
1.3.2.2 +26 -23 jakarta-log4j/src/java/org/apache/log4j/net/SimpleSocketServer.java
Index: SimpleSocketServer.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SimpleSocketServer.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- SimpleSocketServer.java 12 Jun 2002 13:55:32 -0000 1.3.2.1
+++ SimpleSocketServer.java 19 Jun 2002 10:01:05 -0000 1.3.2.2
@@ -13,23 +13,24 @@
import org.apache.log4j.Category;
import org.apache.log4j.LogManager;
import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.xml.DOMConfigurator;
/**
- A simple {@link SocketNode} based server.
-
+ * A simple {@link SocketNode} based server.
+ *
<pre>
- <b>Usage:</b> java org.apache.log4j.net.SimpleSocketServer port configFile
+ <b>Usage:</b> java org.apache.log4j.net.SimpleSocketServer port configFile
- where <em>port</em> is a part number where the server listens and
- <em>configFile</em> is a configuration file fed to the {@link
- PropertyConfigurator}.
+ where <em>port</em> is a part number where the server listens and
+ <em>configFile</em> is a configuration file fed to the {@link
+ PropertyConfigurator} or to {@link DOMConfigurator} if an XML file.
</pre>
-
- @author Ceki Gülcü
-
- @since 0.8.4 */
-
+ *
+ * @author Ceki Gülcü
+ *
+ * @since 0.8.4
+ * */
public class SimpleSocketServer {
static Category cat = Category.getInstance(SimpleSocketServer.class.getName());
@@ -39,11 +40,12 @@
public
static
void main(String argv[]) {
- if(argv.length == 2)
+ if(argv.length == 2) {
init(argv[0], argv[1]);
- else
+ } else {
usage("Wrong number of arguments.");
-
+ }
+
try {
cat.info("Listening on port " + port);
ServerSocket serverSocket = new ServerSocket(port);
@@ -55,30 +57,31 @@
new Thread(new SocketNode(socket,
LogManager.getLoggerRepository())).start();
}
- }
- catch(Exception e) {
+ } catch(Exception e) {
e.printStackTrace();
}
}
- static
- void usage(String msg) {
+ static void usage(String msg) {
System.err.println(msg);
System.err.println(
"Usage: java " +SimpleSocketServer.class.getName() + " port configFile");
System.exit(1);
}
- static
- void init(String portStr, String configFile) {
+ static void init(String portStr, String configFile) {
try {
port = Integer.parseInt(portStr);
- }
- catch(java.lang.NumberFormatException e) {
+ } catch(java.lang.NumberFormatException e) {
e.printStackTrace();
usage("Could not interpret port number ["+ portStr +"].");
}
- PropertyConfigurator.configure(configFile);
+
+ if(configFile.endsWith(".xml")) {
+ new DOMConfigurator().configure(configFile);
+ } else {
+ new PropertyConfigurator().configure(configFile);
+ }
}
}
1.20.2.1 +6 -4 jakarta-log4j/src/java/org/apache/log4j/net/SocketNode.java
Index: SocketNode.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/net/SocketNode.java,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -r1.20 -r1.20.2.1
--- SocketNode.java 9 May 2002 19:53:37 -0000 1.20
+++ SocketNode.java 19 Jun 2002 10:01:05 -0000 1.20.2.1
@@ -39,8 +39,7 @@
static Logger logger = Logger.getLogger(SocketNode.class);
- public
- SocketNode(Socket socket, LoggerRepository hierarchy) {
+ public SocketNode(Socket socket, LoggerRepository hierarchy) {
this.socket = socket;
this.hierarchy = hierarchy;
try {
@@ -64,15 +63,18 @@
try {
while(true) {
+ // read an event from the wire
event = (LoggingEvent) ois.readObject();
+ // get a logger from the hierarchy. The name of the logger is taken to be the name contained in the event.
remoteLogger = hierarchy.getLogger(event.categoryName);
event.logger = remoteLogger;
+ // apply the logger-level filter
if(event.level.isGreaterOrEqual(remoteLogger.getEffectiveLevel())) {
+ // finally log the event as if was generated locally
remoteLogger.callAppenders(event);
}
}
- }
- catch(java.io.EOFException e) {
+ } catch(java.io.EOFException e) {
logger.info("Caught java.io.EOFException closing conneciton.");
} catch(java.net.SocketException e) {
logger.info("Caught java.net.SocketException closing conneciton.");
No revision
No revision
1.1.2.3 +16 -43 jakarta-log4j/src/xdocs/lf5/Attic/examples.xml
Index: examples.xml
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/xdocs/lf5/Attic/examples.xml,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- examples.xml 12 Jun 2002 21:31:35 -0000 1.1.2.2
+++ examples.xml 19 Jun 2002 10:01:05 -0000 1.1.2.3
@@ -26,11 +26,16 @@
<h4>Running the Example:</h4>
<p>Let <code>LOG4J_HOME</code> be the the directory where you
- installed log4j.</p>
+ installed log4j and let VERSION stand for the log4j version.</p>
<ul>
+ <li>Ensure that <i>LOG4J_HOME/dist/lib/log4j-VERSION.jar</i>
+ is in your CLASSPATH.</li>
+
<li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
+ CLASSPATH. This directory contains the binary class files for
+ running the lf5 examples. <em>It is not needed under normal
+ operational circumstances.</em> </li>
<li>Ensure that a JAXP compatible XML parser is in is in your
CLASSPATH.</li>
@@ -75,16 +80,12 @@
installed log4j.</p>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:
<p><b> java
- examples.lf5.InitUsingPropertiesFile</b>.<b>InitUsingPropertiesFile</b></p>x
+ examples.lf5.InitUsingPropertiesFile</b>.<b>InitUsingPropertiesFile</b></p>
</li>
</ul>
@@ -125,11 +126,7 @@
installed log4j.</p>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:
@@ -188,11 +185,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Copy the provided
<i>LOG4J_HOME/examples/lf5/InitUsingLog4JProperties/log4j.properties</i>
@@ -279,11 +272,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:
@@ -362,11 +351,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li> Start the SocketServer using the following command: </li>
@@ -469,11 +454,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:<b> java
org.apache.log4j.lf5.StartLogFactor5</b>
@@ -521,11 +502,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:
@@ -574,11 +551,7 @@
<h4>Running the Example:</h4>
<ul>
- <li>Ensure that <i>LOG4J_HOME/dist/classes</i> is in your
- CLASSPATH.</li>
-
- <li>Ensure that a JAXP compatible XML parser is in is in your
- CLASSPATH.</li>
+ <li>Set up your CLASSPATH as in Example 1 above.</li>
<li>Type<b> </b>the following at the command line:
1.1.2.2 +22 -17 jakarta-log4j/src/xdocs/lf5/Attic/faq.xml
Index: faq.xml
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/xdocs/lf5/Attic/faq.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- faq.xml 11 Jun 2002 22:00:56 -0000 1.1.2.1
+++ faq.xml 19 Jun 2002 10:01:05 -0000 1.1.2.2
@@ -12,28 +12,33 @@
<p><b>Q. What is LogFactor5?</b> </p>
- <p><b>A.</b> LogFactor5 is a Swing based GUI that leverages the power of Apache's
- Log4J logging toolkit and provides developers with a sophisticated, feature-rich,
- logging interface for managing log messages.</p>
+ <p><b>A.</b> LogFactor5 is a Swing based GUI that leverages the
+ power of log4j to provide developers with a sophisticated,
+ feature-rich, visual tool for managing log messages.</p>
+
<hr/>
- <p><b>Q. Do I need to know how to use Log4J in order to use LogFactor5?</b></p>
+ <p><b>Q. Do I need to know how to use log4j in order to use LogFactor5?</b></p>
- <p><b>A.</b> Yes, the documentation for LogFactor5 assumes the user has some understanding
- of how Log4J works. Note however that the LogFactor5 examples will run regardless
- of a user's Log4J knowledge level.</p>
- <hr/>
+ <p><b>A.</b> Yes, the documentation for LogFactor5 assumes the
+ user has some understanding of how log4j works. Note however
+ that the LogFactor5 examples will run regardless of a user's
+ log4j knowledge level.</p> <hr/>
<p><b>Q. What are the memory requirements for LogFactor5?</b></p>
- <p><b>A.</b> The LogFactor5 logging console window uses around 13 MB of memory
- to run on a Windows OS. Our memory profiling has shown that with a logging message
- of 25 words in length, and a stack trace nested seven methods deep, every 1000
- records displayed in the logging console uses about 6.5 MB of memory. For this
- reason, when you are setting the maximum number of log records to be shown,
- you should be careful that you have enough memory to display all of the records.
- The default maximum number of records that will be displayed is set to 5000
- to minimize the possibility of running out of memory. We recommend that Windows
- users have at least 96 MB of RAM when using LogFactor5.</p>
+
+ <p><b>A.</b> The LogFactor5 logging console window uses around
+ 13 MB of memory to run on a Windows OS. Our memory profiling
+ has shown that with a logging message of 25 words in length,
+ and a stack trace nested seven methods deep, every 1000
+ records displayed in the logging console uses about 6.5 MB of
+ memory. For this reason, when you are setting the maximum
+ number of log records to be shown, you should be careful that
+ you have enough memory to display all of the records. The
+ default maximum number of records that will be displayed is
+ set to 5000 to minimize the possibility of running out of
+ memory. We recommend that Windows users have at least 96 MB of
+ RAM when using LogFactor5.</p>
</section>
</body>
1.1.2.3 +3 -2 jakarta-log4j/src/xdocs/lf5/Attic/trouble.xml
Index: trouble.xml
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/xdocs/lf5/Attic/trouble.xml,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- trouble.xml 11 Jun 2002 22:00:56 -0000 1.1.2.2
+++ trouble.xml 19 Jun 2002 10:01:05 -0000 1.1.2.3
@@ -20,9 +20,10 @@
logs to both the LogFactor5 console and a rolling log
file.</p>
-<pre><font face="Courier New, Courier, mono"># Register both appenders with the root of the Category tree.
+<pre><font face="Courier New, Courier, mono"># Register both appenders
+with the root of the logger tree.
-log4j.rootCategory=, A1, R
+log4j.rootLogger=, A1, R
# A1 is set to be a LF5Appender which outputs to a swing
# logging console.