Run Sort.java Example in log4j-1.2.17.zip

Q

How to run the Sort.java example program in log4j-1.2.17.zip? I have log4j-1.2.17.zip installed at \fyicenter\apache-log4j-1.2.17 folder.

✍: FYIcenter.com

A

Sort.java is an example program provided in the log4j-1.2.17.zip. It is used to show you how to use Log4j with the properties file configuration. Here are files and locations related to Sort.java example:

05/06/2012  01:00 PM             3,231 Sort.java
05/06/2012  01:00 PM             2,872 SortAlgo.java
05/06/2012  01:00 PM             1,845 sort1.properties
05/06/2012  01:00 PM             2,877 sort2.properties
05/06/2012  01:00 PM             1,848 sort3.properties
05/06/2012  01:00 PM             1,970 sort4.properties

Let's run the Sort.java with the first configuration file, sort1.properties:

\fyicenter>cd \fyicenter\apache-log4j-1.2.17

\fyicenter\apache-log4j-1.2.17>java -version
java version "1.7.0_45"

\fyicenter\apache-log4j-1.2.17>javac -cp .;log4j-1.2.17.jar examples\Sort.java

\fyicenter\apache-log4j-1.2.17>java -cp .;log4j-1.2.17.jar examples.Sort 
   examples\sort1.properties 10

0  INFO  [main] examples.Sort         - Populating an array of 10 elements 
                                        in reverse order.
2  INFO  [main] examples.SortAlgo     - Entered the sort method.
3  DEBUG [main] examples.SortAlgo.OUTER i=9 - in outer loop.
3  DEBUG [main] examples.SortAlgo.INNER i=9 j=0 - in inner loop.
3  DEBUG [main] examples.SortAlgo.SWAP  i=9 j=0 - Swapping intArray[0]=9 
                                        and intArray[1]=8
3  DEBUG [main] examples.SortAlgo.INNER i=9 j=1 - in inner loop.
...
18 DEBUG [main] examples.SortAlgo.OUTER i=1 - in outer loop.
18 DEBUG [main] examples.SortAlgo.INNER i=1 j=0 - in inner loop.
18 DEBUG [main] examples.SortAlgo.SWAP  i=1 j=0 - Swapping intArray[0]=1 
                                        and intArray[1]=0
18 DEBUG [main] examples.SortAlgo.OUTER i=0 - in outer loop.
18 INFO  [main] examples.SortAlgo.DUMP     - Dump of integer array:
18 INFO  [main] examples.SortAlgo.DUMP     - Element [0]=0
18 INFO  [main] examples.SortAlgo.DUMP     - Element [1]=1
19 INFO  [main] examples.SortAlgo.DUMP     - Element [2]=2
19 INFO  [main] examples.SortAlgo.DUMP     - Element [3]=3
19 INFO  [main] examples.SortAlgo.DUMP     - Element [4]=4
19 INFO  [main] examples.SortAlgo.DUMP     - Element [5]=5
19 INFO  [main] examples.SortAlgo.DUMP     - Element [6]=6
19 INFO  [main] examples.SortAlgo.DUMP     - Element [7]=7
19 INFO  [main] examples.SortAlgo.DUMP     - Element [8]=8
19 INFO  [main] examples.SortAlgo.DUMP     - Element [9]=9
19 INFO  [main] examples.Sort - The next log statement should be an error message.
19 ERROR [main] examples.SortAlgo.DUMP     - Tried to dump an uninitialized array.
20 INFO  [main] examples.Sort - Exiting main method.

 

Sort.java with sort2.properties in log4j-1.2.17.zip

Run Trivial.java Example in log4j-1.2.17.zip

Using Apache Log4j 1.x in Java Programs

⇑⇑ FAQ for Apache Log4j

2016-06-27, 2554🔥, 0💬