KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > util > Log4Echo


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: Log4Echo.java 42720 2004-03-16 22:56:15Z michi $ */
19
20 package org.apache.lenya.util;
21
22 import org.apache.log4j.Category;
23
24
25 /**
26  * Can be used within shell scripts resp. batch files
27  */

28 public class Log4Echo {
29     private static Category log = Category.getInstance(Log4Echo.class);
30     
31     /**
32      * main
33      *
34      * @param args DOCUMENT ME!
35      */

36     public static void main(String JavaDoc[] args) {
37         if (args.length != 2) {
38             System.err.println("Usage: java " + new Log4Echo().getClass().getName() + "log-level log-message");
39             return;
40         }
41
42         String JavaDoc level = args[0].toLowerCase();
43         String JavaDoc message = args[1];
44         if (level.equals("debug")) {
45             log.debug(message);
46         } else if (level.equals("info")) {
47             log.info(message);
48         } else if (level.equals("warn")) {
49             log.warn(message);
50         } else if (level.equals("error")) {
51             log.error(message);
52         } else if (level.equals("fatal")) {
53             log.fatal(message);
54         } else {
55             log.error("No such log level: " + level + " " + message);
56         }
57     }
58 }
59
Popular Tags