You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by br...@apache.org on 2002/07/12 20:39:13 UTC
cvs commit: jakarta-log4j/examples/lf5/UsingSocketAppenders UsingSocketAppenders.java
bradm 2002/07/12 11:39:13
Modified: examples/lf5/UsingLogMonitorAdapter Tag: v1_2-branch
CustomizedLogLevels.java
UsingLogMonitorAdapter.java
examples/lf5/InitUsingDefaultConfigurator Tag: v1_2-branch
InitUsingDefaultConfigurator.java
examples/lf5/InitUsingLog4JProperties Tag: v1_2-branch
InitUsingLog4JProperties.java
examples/lf5/InitUsingMultipleAppenders Tag: v1_2-branch
InitUsingMultipleAppenders.java
examples/lf5/InitUsingPropertiesFile Tag: v1_2-branch
InitUsingPropertiesFile.java
examples/lf5/InitUsingXMLPropertiesFile Tag: v1_2-branch
InitUsingXMLPropertiesFile.java
examples/lf5/UsingSocketAppenders Tag: v1_2-branch
UsingSocketAppenders.java
Log:
changed examples to work with Logger rather than Category
Revision Changes Path
No revision
No revision
1.1.2.2 +68 -69 jakarta-log4j/examples/lf5/UsingLogMonitorAdapter/Attic/CustomizedLogLevels.java
Index: CustomizedLogLevels.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/UsingLogMonitorAdapter/Attic/CustomizedLogLevels.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CustomizedLogLevels.java 12 Jun 2002 21:06:28 -0000 1.1.2.1
+++ CustomizedLogLevels.java 12 Jul 2002 18:39:12 -0000 1.1.2.2
@@ -9,7 +9,6 @@
package examples.lf5.UsingLogMonitorAdapter;
import org.apache.log4j.lf5.LogLevel;
-import org.apache.log4j.lf5.util.AdapterLogRecord;
import org.apache.log4j.lf5.util.LogMonitorAdapter;
/**
@@ -26,74 +25,74 @@
// Contributed by ThoughtWorks Inc.
public class CustomizedLogLevels {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
- public final static LogLevel LEVEL_ONE = new LogLevel("LEVEL 1", 1);
- public final static LogLevel LEVEL_TWO = new LogLevel("LEVEL 2", 2);
- public final static LogLevel LEVEL_THREE = new LogLevel("LEVEL 3", 3);
- public final static LogLevel LEVEL_FOUR = new LogLevel("LEVEL 4", 4);
- public final static LogLevel DEFAULT = new LogLevel("DEFAULT", 0);
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
- private static LogMonitorAdapter _adapter;
-
- static {
- // The first LogLevel in the Array will be used as the default LogLevel.
- _adapter = LogMonitorAdapter.newInstance(new LogLevel[]{DEFAULT, LEVEL_ONE,
- LEVEL_TWO, LEVEL_THREE, LEVEL_FOUR, LogLevel.FATAL});
- // if a different log level is to be used it can be specified as such
- // _adapter.setDefaultLevel(LEVEL_THREE);
- }
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String[] args) {
- CustomizedLogLevels test = new CustomizedLogLevels();
- test.doMyBidding();
- }
-
- public void doMyBidding() {
- // tell the LogMonitorAdapter which LogLevel is the severe Level if necessary
- _adapter.setSevereLevel(LEVEL_ONE);
-
- String levels = this.getClass().getName();
-
- // will used the default Level
- _adapter.log(levels, "Using the customized LogLevels");
-
- _adapter.log(levels, LEVEL_FOUR, "This is a test");
- _adapter.log(levels, LEVEL_THREE, "Hmmm fobidden doughnut");
- _adapter.log(levels, LEVEL_ONE, "Danger Danger Will Robinson",
- new RuntimeException("DANGER"), "32");
- _adapter.log(levels, LEVEL_TWO, "Exit stage right->");
- _adapter.log(levels, LEVEL_FOUR, "What's up Doc?",
- new NullPointerException("Unfortunate exception"));
-
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+ public final static LogLevel LEVEL_ONE = new LogLevel("LEVEL 1", 1);
+ public final static LogLevel LEVEL_TWO = new LogLevel("LEVEL 2", 2);
+ public final static LogLevel LEVEL_THREE = new LogLevel("LEVEL 3", 3);
+ public final static LogLevel LEVEL_FOUR = new LogLevel("LEVEL 4", 4);
+ public final static LogLevel DEFAULT = new LogLevel("DEFAULT", 0);
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+ private static LogMonitorAdapter _adapter;
+
+ static {
+ // The first LogLevel in the Array will be used as the default LogLevel.
+ _adapter = LogMonitorAdapter.newInstance(new LogLevel[]{DEFAULT, LEVEL_ONE,
+ LEVEL_TWO, LEVEL_THREE, LEVEL_FOUR, LogLevel.FATAL});
+ // if a different log level is to be used it can be specified as such
+ // _adapter.setDefaultLevel(LEVEL_THREE);
+ }
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String[] args) {
+ CustomizedLogLevels test = new CustomizedLogLevels();
+ test.doMyBidding();
+ }
+
+ public void doMyBidding() {
+ // tell the LogMonitorAdapter which LogLevel is the severe Level if necessary
+ _adapter.setSevereLevel(LEVEL_ONE);
+
+ String levels = this.getClass().getName();
+
+ // will used the default Level
+ _adapter.log(levels, "Using the customized LogLevels");
+
+ _adapter.log(levels, LEVEL_FOUR, "This is a test");
+ _adapter.log(levels, LEVEL_THREE, "Hmmm fobidden doughnut");
+ _adapter.log(levels, LEVEL_ONE, "Danger Danger Will Robinson",
+ new RuntimeException("DANGER"), "32");
+ _adapter.log(levels, LEVEL_TWO, "Exit stage right->");
+ _adapter.log(levels, LEVEL_FOUR, "What's up Doc?",
+ new NullPointerException("Unfortunate exception"));
+
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
1.1.2.2 +6 -6 jakarta-log4j/examples/lf5/UsingLogMonitorAdapter/Attic/UsingLogMonitorAdapter.java
Index: UsingLogMonitorAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/UsingLogMonitorAdapter/Attic/UsingLogMonitorAdapter.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- UsingLogMonitorAdapter.java 12 Jun 2002 21:06:28 -0000 1.1.2.1
+++ UsingLogMonitorAdapter.java 12 Jul 2002 18:39:12 -0000 1.1.2.2
@@ -54,16 +54,16 @@
}
public void doMyBidding() {
- String category = this.getClass().getName();
+ String logger = this.getClass().getName();
// will default to debug log level
- _adapter.log(category, "Doh this is a debugging");
+ _adapter.log(logger, "Doh this is a debugging");
- _adapter.log(category, LogLevel.INFO, "Hmmm fobidden doughnut");
- _adapter.log(category, LogLevel.WARN, "Danger Danger Will Robinson",
+ _adapter.log(logger, LogLevel.INFO, "Hmmm fobidden doughnut");
+ _adapter.log(logger, LogLevel.WARN, "Danger Danger Will Robinson",
new RuntimeException("DANGER"), "32");
- _adapter.log(category, LogLevel.ERROR, "Exit stage right->");
- _adapter.log(category, LogLevel.FATAL, "What's up Doc?",
+ _adapter.log(logger, LogLevel.ERROR, "Exit stage right->");
+ _adapter.log(logger, LogLevel.FATAL, "What's up Doc?",
new NullPointerException("Unfortunate exception"));
}
No revision
No revision
1.1.2.2 +91 -96 jakarta-log4j/examples/lf5/InitUsingDefaultConfigurator/Attic/InitUsingDefaultConfigurator.java
Index: InitUsingDefaultConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/InitUsingDefaultConfigurator/Attic/InitUsingDefaultConfigurator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- InitUsingDefaultConfigurator.java 12 Jun 2002 21:06:27 -0000 1.1.2.1
+++ InitUsingDefaultConfigurator.java 12 Jul 2002 18:39:12 -0000 1.1.2.2
@@ -7,11 +7,9 @@
*/
package examples.lf5.InitUsingDefaultConfigurator;
-import org.apache.log4j.lf5.DefaultLF5Configurator;
-import org.apache.log4j.lf5.LogLevel;
-import org.apache.log4j.lf5.util.LogMonitorAdapter;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
+import org.apache.log4j.lf5.DefaultLF5Configurator;
import java.io.IOException;
@@ -20,109 +18,106 @@
* logging window using the DefaultLF5Configurator.
*
* The DefaultLF5Configurator uses a default configuration file stored
- * in the lf5.jar in order to provide a default configuration for
+ * in the log4j.jar in order to provide a default configuration for
* the LF5Appender.
*
- * To make this example work, ensure that the lf5.jar and lf5-license.jar
- * files are in your classpath, and then run the example at the command line.
- *
* @author Brent Sprecher
*/
// Contributed by ThoughtWorks Inc.
public class InitUsingDefaultConfigurator {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
- private static Category cat =
- Category.getInstance(InitUsingDefaultConfigurator.class);
-
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String[] args) throws IOException {
- // Configure the LF5Appender using the DefaultLF5Configurator. This
- // will add the LF5Appender to the root of the Category tree.
- DefaultLF5Configurator.configure();
-
- // Add an NDC to demonstrate how NDC information is output.
- NDC.push("#23856");
- // Log some information.
- for (int i = 0; i < 10; i++) {
- cat.debug("Hello, my name is Homer Simpson.");
- cat.info("Mmmmmm .... Chocolate.");
- cat.warn("Mmm...forbidden donut.");
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+ private static Logger logger =
+ Logger.getLogger(InitUsingDefaultConfigurator.class);
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String[] args) throws IOException {
+ // Configure the LF5Appender using the DefaultLF5Configurator. This
+ // will add the LF5Appender to the root of the Category tree.
+ DefaultLF5Configurator.configure();
+
+ // Add an NDC to demonstrate how NDC information is output.
+ NDC.push("#23856");
+ // Log some information.
+ for (int i = 0; i < 10; i++) {
+ logger.debug("Hello, my name is Homer Simpson.");
+ logger.info("Mmmmmm .... Chocolate.");
+ logger.warn("Mmm...forbidden donut.");
+ }
+ // Clean up NDC
+ NDC.pop();
+ NDC.remove();
+
+ NDC.push("Another NDC");
+ // Log some information.
+ logger.fatal("Hello, my name is Bart Simpson.");
+ logger.error("Hi diddly ho good neighbour.");
+ // Clean up NDC
+ NDC.pop();
+ NDC.remove();
+
+ // Call methods on both classes.
+ InitUsingDefaultConfigurator.foo();
+ InnerInitUsingDefaultConfigurator.foo();
+
+ logger.info("Exiting InitUsingDefaultConfigurator.");
+
}
- // Clean up NDC
- NDC.pop();
- NDC.remove();
-
- NDC.push("Another NDC");
- // Log some information.
- cat.fatal("Hello, my name is Bart Simpson.");
- cat.error("Hi diddly ho good neighbour.");
- // Clean up NDC
- NDC.pop();
- NDC.remove();
-
- // Call methods on both classes.
- InitUsingDefaultConfigurator.foo();
- InnerInitUsingDefaultConfigurator.foo();
-
- cat.info("Exiting InitUsingDefaultConfigurator.");
-
- }
-
- public static void foo() {
- cat.debug("Entered foo in InitUsingDefaultConfigurator class");
-
- NDC.push("#123456");
- cat.debug("Hello, my name is Marge Simpson.");
- cat.info("D'oh!! A deer! A female deer.");
- // Clean up NDC
- NDC.pop();
- NDC.remove();
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
-
- public static class InnerInitUsingDefaultConfigurator {
- static Category cat =
- Category.getInstance(InnerInitUsingDefaultConfigurator.class.getName());
-
- static void foo() throws IOException {
- // Configure the LF5Appender again. You can call
- // DefaultLF5Configurator.configure() as often as you want
- // without unexpected behavior.
- DefaultLF5Configurator.configure();
- cat.info("Entered foo in InnerInitUsingDefaultConfigurator class.");
+ public static void foo() {
+ logger.debug("Entered foo in InitUsingDefaultConfigurator class");
+
+ NDC.push("#123456");
+ logger.debug("Hello, my name is Marge Simpson.");
+ logger.info("D'oh!! A deer! A female deer.");
+ // Clean up NDC
+ NDC.pop();
+ NDC.remove();
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
+
+ public static class InnerInitUsingDefaultConfigurator {
+ static Logger logger =
+ Logger.getLogger(InnerInitUsingDefaultConfigurator.class.getName());
+
+ static void foo() throws IOException {
+ // Configure the LF5Appender again. You can call
+ // DefaultLF5Configurator.configure() as often as you want
+ // without unexpected behavior.
+ DefaultLF5Configurator.configure();
+
+ logger.info("Entered foo in InnerInitUsingDefaultConfigurator class.");
+ }
}
- }
}
No revision
No revision
1.1.2.2 +76 -77 jakarta-log4j/examples/lf5/InitUsingLog4JProperties/Attic/InitUsingLog4JProperties.java
Index: InitUsingLog4JProperties.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/InitUsingLog4JProperties/Attic/InitUsingLog4JProperties.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- InitUsingLog4JProperties.java 12 Jun 2002 21:06:27 -0000 1.1.2.1
+++ InitUsingLog4JProperties.java 12 Jul 2002 18:39:12 -0000 1.1.2.2
@@ -7,7 +7,7 @@
*/
package examples.lf5.InitUsingLog4JProperties;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import java.io.IOException;
@@ -26,10 +26,9 @@
* will load the file during class initialization. The LF5Appender will be
* added to the root category of the Category tree.
*
- * To make this example work, ensure that the lf5.jar and lf5-license.jar
- * files are in your classpath. Next, create a log4j.properties file and
- * add this line to it, or add this line to your existing log4j.properties
- * file. Run the example at the command line and explore the results!
+ * Create a log4j.properties file and add this line to it, or add this line
+ * to your existing log4j.properties file. Run the example at the command line
+ * and explore the results!
*
* @author Brent Sprecher
*/
@@ -37,77 +36,77 @@
// Contributed by ThoughtWorks Inc.
public class InitUsingLog4JProperties {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
-
- private static Category cat =
- Category.getInstance(InitUsingLog4JProperties.class);
-
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String argv[]) {
- // Add a bunch of logging statements ...
- cat.debug("Hello, my name is Homer Simpson.");
- cat.debug("Hello, my name is Lisa Simpson.");
- cat.debug("Hello, my name is Marge Simpson.");
- cat.debug("Hello, my name is Bart Simpson.");
- cat.debug("Hello, my name is Maggie Simpson.");
-
- cat.info("We are the Simpsons!");
- cat.info("Mmmmmm .... Chocolate.");
- cat.info("Homer likes chocolate");
- cat.info("Doh!");
- cat.info("We are the Simpsons!");
-
- cat.warn("Bart: I am through with working! Working is for chumps!" +
- "Homer: Son, I'm proud of you. I was twice your age before " +
- "I figured that out.");
- cat.warn("Mmm...forbidden donut.");
- cat.warn("D'oh! A deer! A female deer!");
- cat.warn("Truly, yours is a butt that won't quit." +
- "- Bart, writing as Woodrow to Ms. Krabappel.");
-
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.");
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.",
- new IOException("Dumpsville, USA"));
- cat.error("Mr. Hutz, are you aware you're not wearing pants?");
- cat.error("Mr. Hutz, are you aware you're not wearing pants?",
- new IllegalStateException("Error !!"));
-
-
- cat.fatal("Eep.");
- cat.fatal("Mmm...forbidden donut.",
- new SecurityException("Fatal Exception"));
- cat.fatal("D'oh! A deer! A female deer!");
- cat.fatal("Mmmmmm .... Chocolate.",
- new SecurityException("Fatal Exception"));
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ private static Logger logger =
+ Logger.getLogger(InitUsingLog4JProperties.class);
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String argv[]) {
+ // Add a bunch of logging statements ...
+ logger.debug("Hello, my name is Homer Simpson.");
+ logger.debug("Hello, my name is Lisa Simpson.");
+ logger.debug("Hello, my name is Marge Simpson.");
+ logger.debug("Hello, my name is Bart Simpson.");
+ logger.debug("Hello, my name is Maggie Simpson.");
+
+ logger.info("We are the Simpsons!");
+ logger.info("Mmmmmm .... Chocolate.");
+ logger.info("Homer likes chocolate");
+ logger.info("Doh!");
+ logger.info("We are the Simpsons!");
+
+ logger.warn("Bart: I am through with working! Working is for chumps!" +
+ "Homer: Son, I'm proud of you. I was twice your age before " +
+ "I figured that out.");
+ logger.warn("Mmm...forbidden donut.");
+ logger.warn("D'oh! A deer! A female deer!");
+ logger.warn("Truly, yours is a butt that won't quit." +
+ "- Bart, writing as Woodrow to Ms. Krabappel.");
+
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.");
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.",
+ new IOException("Dumpsville, USA"));
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?");
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?",
+ new IllegalStateException("Error !!"));
+
+
+ logger.fatal("Eep.");
+ logger.fatal("Mmm...forbidden donut.",
+ new SecurityException("Fatal Exception"));
+ logger.fatal("D'oh! A deer! A female deer!");
+ logger.fatal("Mmmmmm .... Chocolate.",
+ new SecurityException("Fatal Exception"));
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
No revision
No revision
1.1.2.2 +80 -81 jakarta-log4j/examples/lf5/InitUsingMultipleAppenders/Attic/InitUsingMultipleAppenders.java
Index: InitUsingMultipleAppenders.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/InitUsingMultipleAppenders/Attic/InitUsingMultipleAppenders.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- InitUsingMultipleAppenders.java 12 Jun 2002 21:06:27 -0000 1.1.2.1
+++ InitUsingMultipleAppenders.java 12 Jul 2002 18:39:13 -0000 1.1.2.2
@@ -7,8 +7,7 @@
*/
package examples.lf5.InitUsingMultipleAppenders;
-import org.apache.log4j.lf5.LogLevel;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.IOException;
@@ -55,84 +54,84 @@
public class InitUsingMultipleAppenders {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
-
- private static Category cat =
- Category.getInstance(InitUsingMultipleAppenders.class);
-
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String argv[]) {
- // Use a PropertyConfigurator to initialize from a property file.
- String resource =
- "/examples/lf5/InitUsingMultipleAppenders/example.properties";
- URL configFileResource =
- InitUsingMultipleAppenders.class.getResource(resource);
- PropertyConfigurator.configure(configFileResource);
-
- // Add a bunch of logging statements ...
- cat.debug("Hello, my name is Homer Simpson.");
- cat.debug("Hello, my name is Lisa Simpson.");
- cat.debug("Hello, my name is Marge Simpson.");
- cat.debug("Hello, my name is Bart Simpson.");
- cat.debug("Hello, my name is Maggie Simpson.");
-
- cat.info("We are the Simpsons!");
- cat.info("Mmmmmm .... Chocolate.");
- cat.info("Homer likes chocolate");
- cat.info("Doh!");
- cat.info("We are the Simpsons!");
-
- cat.warn("Bart: I am through with working! Working is for chumps!" +
- "Homer: Son, I'm proud of you. I was twice your age before " +
- "I figured that out.");
- cat.warn("Mmm...forbidden donut.");
- cat.warn("D'oh! A deer! A female deer!");
- cat.warn("Truly, yours is a butt that won't quit." +
- "- Bart, writing as Woodrow to Ms. Krabappel.");
-
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.");
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.",
- new IOException("Dumpsville, USA"));
- cat.error("Mr. Hutz, are you aware you're not wearing pants?");
- cat.error("Mr. Hutz, are you aware you're not wearing pants?",
- new IllegalStateException("Error !!"));
-
-
- cat.fatal("Eep.");
- cat.fatal("Mmm...forbidden donut.",
- new SecurityException("Fatal Exception"));
- cat.fatal("D'oh! A deer! A female deer!");
- cat.fatal("Mmmmmm .... Chocolate.",
- new SecurityException("Fatal Exception"));
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ private static Logger logger =
+ Logger.getLogger(InitUsingMultipleAppenders.class);
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String argv[]) {
+ // Use a PropertyConfigurator to initialize from a property file.
+ String resource =
+ "/examples/lf5/InitUsingMultipleAppenders/example.properties";
+ URL configFileResource =
+ InitUsingMultipleAppenders.class.getResource(resource);
+ PropertyConfigurator.configure(configFileResource);
+
+ // Add a bunch of logging statements ...
+ logger.debug("Hello, my name is Homer Simpson.");
+ logger.debug("Hello, my name is Lisa Simpson.");
+ logger.debug("Hello, my name is Marge Simpson.");
+ logger.debug("Hello, my name is Bart Simpson.");
+ logger.debug("Hello, my name is Maggie Simpson.");
+
+ logger.info("We are the Simpsons!");
+ logger.info("Mmmmmm .... Chocolate.");
+ logger.info("Homer likes chocolate");
+ logger.info("Doh!");
+ logger.info("We are the Simpsons!");
+
+ logger.warn("Bart: I am through with working! Working is for chumps!" +
+ "Homer: Son, I'm proud of you. I was twice your age before " +
+ "I figured that out.");
+ logger.warn("Mmm...forbidden donut.");
+ logger.warn("D'oh! A deer! A female deer!");
+ logger.warn("Truly, yours is a butt that won't quit." +
+ "- Bart, writing as Woodrow to Ms. Krabappel.");
+
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.");
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.",
+ new IOException("Dumpsville, USA"));
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?");
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?",
+ new IllegalStateException("Error !!"));
+
+
+ logger.fatal("Eep.");
+ logger.fatal("Mmm...forbidden donut.",
+ new SecurityException("Fatal Exception"));
+ logger.fatal("D'oh! A deer! A female deer!");
+ logger.fatal("Mmmmmm .... Chocolate.",
+ new SecurityException("Fatal Exception"));
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
No revision
No revision
1.1.2.2 +80 -81 jakarta-log4j/examples/lf5/InitUsingPropertiesFile/Attic/InitUsingPropertiesFile.java
Index: InitUsingPropertiesFile.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/InitUsingPropertiesFile/Attic/InitUsingPropertiesFile.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- InitUsingPropertiesFile.java 12 Jun 2002 21:06:27 -0000 1.1.2.1
+++ InitUsingPropertiesFile.java 12 Jul 2002 18:39:13 -0000 1.1.2.2
@@ -7,8 +7,7 @@
*/
package examples.lf5.InitUsingPropertiesFile;
-import org.apache.log4j.lf5.LogLevel;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.IOException;
@@ -34,84 +33,84 @@
// Contributed by ThoughtWorks Inc.
public class InitUsingPropertiesFile {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
-
- private static Category cat =
- Category.getInstance(InitUsingPropertiesFile.class);
-
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String argv[]) {
- // Use a PropertyConfigurator to initialize from a property file.
- String resource =
- "/examples/lf5/InitUsingPropertiesFile/example.properties";
- URL configFileResource =
- InitUsingPropertiesFile.class.getResource(resource);
- PropertyConfigurator.configure(configFileResource);
-
- // Add a bunch of logging statements ...
- cat.debug("Hello, my name is Homer Simpson.");
- cat.debug("Hello, my name is Lisa Simpson.");
- cat.debug("Hello, my name is Marge Simpson.");
- cat.debug("Hello, my name is Bart Simpson.");
- cat.debug("Hello, my name is Maggie Simpson.");
-
- cat.info("We are the Simpsons!");
- cat.info("Mmmmmm .... Chocolate.");
- cat.info("Homer likes chocolate");
- cat.info("Doh!");
- cat.info("We are the Simpsons!");
-
- cat.warn("Bart: I am through with working! Working is for chumps!" +
- "Homer: Son, I'm proud of you. I was twice your age before " +
- "I figured that out.");
- cat.warn("Mmm...forbidden donut.");
- cat.warn("D'oh! A deer! A female deer!");
- cat.warn("Truly, yours is a butt that won't quit." +
- "- Bart, writing as Woodrow to Ms. Krabappel.");
-
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.");
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.",
- new IOException("Dumpsville, USA"));
- cat.error("Mr. Hutz, are you aware you're not wearing pants?");
- cat.error("Mr. Hutz, are you aware you're not wearing pants?",
- new IllegalStateException("Error !!"));
-
-
- cat.fatal("Eep.");
- cat.fatal("Mmm...forbidden donut.",
- new SecurityException("Fatal Exception"));
- cat.fatal("D'oh! A deer! A female deer!");
- cat.fatal("Mmmmmm .... Chocolate.",
- new SecurityException("Fatal Exception"));
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ private static Logger logger =
+ Logger.getLogger(InitUsingPropertiesFile.class);
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String argv[]) {
+ // Use a PropertyConfigurator to initialize from a property file.
+ String resource =
+ "/examples/lf5/InitUsingPropertiesFile/example.properties";
+ URL configFileResource =
+ InitUsingPropertiesFile.class.getResource(resource);
+ PropertyConfigurator.configure(configFileResource);
+
+ // Add a bunch of logging statements ...
+ logger.debug("Hello, my name is Homer Simpson.");
+ logger.debug("Hello, my name is Lisa Simpson.");
+ logger.debug("Hello, my name is Marge Simpson.");
+ logger.debug("Hello, my name is Bart Simpson.");
+ logger.debug("Hello, my name is Maggie Simpson.");
+
+ logger.info("We are the Simpsons!");
+ logger.info("Mmmmmm .... Chocolate.");
+ logger.info("Homer likes chocolate");
+ logger.info("Doh!");
+ logger.info("We are the Simpsons!");
+
+ logger.warn("Bart: I am through with working! Working is for chumps!" +
+ "Homer: Son, I'm proud of you. I was twice your age before " +
+ "I figured that out.");
+ logger.warn("Mmm...forbidden donut.");
+ logger.warn("D'oh! A deer! A female deer!");
+ logger.warn("Truly, yours is a butt that won't quit." +
+ "- Bart, writing as Woodrow to Ms. Krabappel.");
+
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.");
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.",
+ new IOException("Dumpsville, USA"));
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?");
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?",
+ new IllegalStateException("Error !!"));
+
+
+ logger.fatal("Eep.");
+ logger.fatal("Mmm...forbidden donut.",
+ new SecurityException("Fatal Exception"));
+ logger.fatal("D'oh! A deer! A female deer!");
+ logger.fatal("Mmmmmm .... Chocolate.",
+ new SecurityException("Fatal Exception"));
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
No revision
No revision
1.1.2.2 +80 -80 jakarta-log4j/examples/lf5/InitUsingXMLPropertiesFile/Attic/InitUsingXMLPropertiesFile.java
Index: InitUsingXMLPropertiesFile.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/InitUsingXMLPropertiesFile/Attic/InitUsingXMLPropertiesFile.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- InitUsingXMLPropertiesFile.java 12 Jun 2002 21:06:27 -0000 1.1.2.1
+++ InitUsingXMLPropertiesFile.java 12 Jul 2002 18:39:13 -0000 1.1.2.2
@@ -7,7 +7,7 @@
*/
package examples.lf5.InitUsingXMLPropertiesFile;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import java.io.IOException;
@@ -27,84 +27,84 @@
// Contributed by ThoughtWorks Inc.
public class InitUsingXMLPropertiesFile {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
-
- private static Category cat =
- Category.getInstance(InitUsingXMLPropertiesFile.class);
-
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String argv[]) {
- // Use a PropertyConfigurator to initialize from a property file.
- String resource =
- "/examples/lf5/InitUsingXMLPropertiesFile/example.xml";
- URL configFileResource =
- InitUsingXMLPropertiesFile.class.getResource(resource);
- DOMConfigurator.configure(configFileResource.getFile());
-
- // Add a bunch of logging statements ...
- cat.debug("Hello, my name is Homer Simpson.");
- cat.debug("Hello, my name is Lisa Simpson.");
- cat.debug("Hello, my name is Marge Simpson.");
- cat.debug("Hello, my name is Bart Simpson.");
- cat.debug("Hello, my name is Maggie Simpson.");
-
- cat.info("We are the Simpsons!");
- cat.info("Mmmmmm .... Chocolate.");
- cat.info("Homer likes chocolate");
- cat.info("Doh!");
- cat.info("We are the Simpsons!");
-
- cat.warn("Bart: I am through with working! Working is for chumps!" +
- "Homer: Son, I'm proud of you. I was twice your age before " +
- "I figured that out.");
- cat.warn("Mmm...forbidden donut.");
- cat.warn("D'oh! A deer! A female deer!");
- cat.warn("Truly, yours is a butt that won't quit." +
- "- Bart, writing as Woodrow to Ms. Krabappel.");
-
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.");
- cat.error("Dear Baby, Welcome to Dumpsville. Population: you.",
- new IOException("Dumpsville, USA"));
- cat.error("Mr. Hutz, are you aware you're not wearing pants?");
- cat.error("Mr. Hutz, are you aware you're not wearing pants?",
- new IllegalStateException("Error !!"));
-
-
- cat.fatal("Eep.");
- cat.fatal("Mmm...forbidden donut.",
- new SecurityException("Fatal Exception"));
- cat.fatal("D'oh! A deer! A female deer!");
- cat.fatal("Mmmmmm .... Chocolate.",
- new SecurityException("Fatal Exception"));
- }
-
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ private static Logger logger =
+ Logger.getLogger(InitUsingXMLPropertiesFile.class);
+
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String argv[]) {
+ // Use a PropertyConfigurator to initialize from a property file.
+ String resource =
+ "/examples/lf5/InitUsingXMLPropertiesFile/example.xml";
+ URL configFileResource =
+ InitUsingXMLPropertiesFile.class.getResource(resource);
+ DOMConfigurator.configure(configFileResource.getFile());
+
+ // Add a bunch of logging statements ...
+ logger.debug("Hello, my name is Homer Simpson.");
+ logger.debug("Hello, my name is Lisa Simpson.");
+ logger.debug("Hello, my name is Marge Simpson.");
+ logger.debug("Hello, my name is Bart Simpson.");
+ logger.debug("Hello, my name is Maggie Simpson.");
+
+ logger.info("We are the Simpsons!");
+ logger.info("Mmmmmm .... Chocolate.");
+ logger.info("Homer likes chocolate");
+ logger.info("Doh!");
+ logger.info("We are the Simpsons!");
+
+ logger.warn("Bart: I am through with working! Working is for chumps!" +
+ "Homer: Son, I'm proud of you. I was twice your age before " +
+ "I figured that out.");
+ logger.warn("Mmm...forbidden donut.");
+ logger.warn("D'oh! A deer! A female deer!");
+ logger.warn("Truly, yours is a butt that won't quit." +
+ "- Bart, writing as Woodrow to Ms. Krabappel.");
+
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.");
+ logger.error("Dear Baby, Welcome to Dumpsville. Population: you.",
+ new IOException("Dumpsville, USA"));
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?");
+ logger.error("Mr. Hutz, are you aware you're not wearing pants?",
+ new IllegalStateException("Error !!"));
+
+
+ logger.fatal("Eep.");
+ logger.fatal("Mmm...forbidden donut.",
+ new SecurityException("Fatal Exception"));
+ logger.fatal("D'oh! A deer! A female deer!");
+ logger.fatal("Mmmmmm .... Chocolate.",
+ new SecurityException("Fatal Exception"));
+ }
+
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
No revision
No revision
1.1.2.2 +93 -93 jakarta-log4j/examples/lf5/UsingSocketAppenders/Attic/UsingSocketAppenders.java
Index: UsingSocketAppenders.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/examples/lf5/UsingSocketAppenders/Attic/UsingSocketAppenders.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- UsingSocketAppenders.java 12 Jun 2002 21:06:28 -0000 1.1.2.1
+++ UsingSocketAppenders.java 12 Jul 2002 18:39:13 -0000 1.1.2.2
@@ -8,7 +8,7 @@
package examples.lf5.UsingSocketAppenders;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import java.io.IOException;
@@ -34,99 +34,99 @@
// Contributed by ThoughtWorks Inc.
public class UsingSocketAppenders {
- //--------------------------------------------------------------------------
- // Constants:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Protected Variables:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Variables:
- //--------------------------------------------------------------------------
-
- private static Category cat1 =
- Category.getInstance(UsingSocketAppenders.class);
- private static Category cat2 =
- Category.getInstance("TestClass.Subclass");
- private static Category cat3 =
- Category.getInstance("TestClass.Subclass.Subclass");
- //--------------------------------------------------------------------------
- // Constructors:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Public Methods:
- //--------------------------------------------------------------------------
-
- public static void main(String argv[]) {
- // Use a PropertyConfigurator to initialize from a property file.
- String resource =
- "/examples/lf5/UsingSocketAppenders/socketclient.properties";
- URL configFileResource =
- UsingSocketAppenders.class.getResource(resource);
- PropertyConfigurator.configure(configFileResource);
-
- // Add a bunch of logging statements ...
- cat1.debug("Hello, my name is Homer Simpson.");
- cat1.debug("Hello, my name is Lisa Simpson.");
- cat2.debug("Hello, my name is Marge Simpson.");
- cat2.debug("Hello, my name is Bart Simpson.");
- cat3.debug("Hello, my name is Maggie Simpson.");
-
- cat2.info("We are the Simpsons!");
- cat2.info("Mmmmmm .... Chocolate.");
- cat3.info("Homer likes chocolate");
- cat3.info("Doh!");
- cat3.info("We are the Simpsons!");
-
- cat1.warn("Bart: I am through with working! Working is for chumps!" +
- "Homer: Son, I'm proud of you. I was twice your age before " +
- "I figured that out.");
- cat1.warn("Mmm...forbidden donut.");
- cat1.warn("D'oh! A deer! A female deer!");
- cat1.warn("Truly, yours is a butt that won't quit." +
- "- Bart, writing as Woodrow to Ms. Krabappel.");
-
- cat2.error("Dear Baby, Welcome to Dumpsville. Population: you.");
- cat2.error("Dear Baby, Welcome to Dumpsville. Population: you.",
- new IOException("Dumpsville, USA"));
- cat3.error("Mr. Hutz, are you aware you're not wearing pants?");
- cat3.error("Mr. Hutz, are you aware you're not wearing pants?",
- new IllegalStateException("Error !!"));
-
-
- cat3.fatal("Eep.");
-
- cat3.fatal("Mmm...forbidden donut.",
- new SecurityException("Fatal Exception ... "));
-
- cat3.fatal("D'oh! A deer! A female deer!");
- cat2.fatal("Mmmmmm .... Chocolate.",
- new SecurityException("Fatal Exception"));
-
- // Put the main thread is put to sleep for 5 seconds to allow the
- // SocketServer to process all incoming messages before the Socket is
- // closed. This is done to overcome some basic limitations with the
- // way the SocketServer and SocketAppender classes manage sockets.
- try {
- Thread.currentThread().sleep(5000);
- } catch (InterruptedException ie) {
- }
+ //--------------------------------------------------------------------------
+ // Constants:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Protected Variables:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Variables:
+ //--------------------------------------------------------------------------
+
+ private static Logger logger1 =
+ Logger.getLogger(UsingSocketAppenders.class);
+ private static Logger logger2 =
+ Logger.getLogger("TestClass.Subclass");
+ private static Logger logger3 =
+ Logger.getLogger("TestClass.Subclass.Subclass");
+ //--------------------------------------------------------------------------
+ // Constructors:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Public Methods:
+ //--------------------------------------------------------------------------
+
+ public static void main(String argv[]) {
+ // Use a PropertyConfigurator to initialize from a property file.
+ String resource =
+ "/examples/lf5/UsingSocketAppenders/socketclient.properties";
+ URL configFileResource =
+ UsingSocketAppenders.class.getResource(resource);
+ PropertyConfigurator.configure(configFileResource);
+
+ // Add a bunch of logging statements ...
+ logger1.debug("Hello, my name is Homer Simpson.");
+ logger1.debug("Hello, my name is Lisa Simpson.");
+ logger2.debug("Hello, my name is Marge Simpson.");
+ logger2.debug("Hello, my name is Bart Simpson.");
+ logger3.debug("Hello, my name is Maggie Simpson.");
+
+ logger2.info("We are the Simpsons!");
+ logger2.info("Mmmmmm .... Chocolate.");
+ logger3.info("Homer likes chocolate");
+ logger3.info("Doh!");
+ logger3.info("We are the Simpsons!");
+
+ logger1.warn("Bart: I am through with working! Working is for chumps!" +
+ "Homer: Son, I'm proud of you. I was twice your age before " +
+ "I figured that out.");
+ logger1.warn("Mmm...forbidden donut.");
+ logger1.warn("D'oh! A deer! A female deer!");
+ logger1.warn("Truly, yours is a butt that won't quit." +
+ "- Bart, writing as Woodrow to Ms. Krabappel.");
+
+ logger2.error("Dear Baby, Welcome to Dumpsville. Population: you.");
+ logger2.error("Dear Baby, Welcome to Dumpsville. Population: you.",
+ new IOException("Dumpsville, USA"));
+ logger3.error("Mr. Hutz, are you aware you're not wearing pants?");
+ logger3.error("Mr. Hutz, are you aware you're not wearing pants?",
+ new IllegalStateException("Error !!"));
+
+
+ logger3.fatal("Eep.");
+
+ logger3.fatal("Mmm...forbidden donut.",
+ new SecurityException("Fatal Exception ... "));
+
+ logger3.fatal("D'oh! A deer! A female deer!");
+ logger2.fatal("Mmmmmm .... Chocolate.",
+ new SecurityException("Fatal Exception"));
+
+ // Put the main thread is put to sleep for 5 seconds to allow the
+ // SocketServer to process all incoming messages before the Socket is
+ // closed. This is done to overcome some basic limitations with the
+ // way the SocketServer and SocketAppender classes manage sockets.
+ try {
+ Thread.currentThread().sleep(5000);
+ } catch (InterruptedException ie) {
+ }
- }
+ }
- //--------------------------------------------------------------------------
- // Protected Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Private Methods:
- //--------------------------------------------------------------------------
-
- //--------------------------------------------------------------------------
- // Nested Top-Level Classes or Interfaces:
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // Protected Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Private Methods:
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ // Nested Top-Level Classes or Interfaces:
+ //--------------------------------------------------------------------------
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>