1 /*
2 * Copyright 2001-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 package org.jdiagnose.library.logging;
17
18 import org.apache.log4j.Category;
19 import org.apache.log4j.Priority;
20 import org.jdiagnose.remote.file.Emitter;
21
22 /***
23 * @author jmccrindle
24 */
25 public class Log4jEmitter implements Emitter {
26
27 Category log = null;
28 Priority priority = Priority.DEBUG;
29
30 public Log4jEmitter() {
31 log = Category.getInstance(Log4jEmitter.class);
32 }
33
34 public Log4jEmitter(String category) {
35 log = Category.getInstance(category);
36 }
37
38 /* (non-Javadoc)
39 * @see org.jdiagnose.remote.file.Emitter#emit(java.lang.StringBuffer)
40 */
41 public void emit(StringBuffer value) {
42 log.log(priority, value);
43 }
44
45 public void setPriority(String priority) {
46 this.priority = Priority.toPriority(priority, Priority.DEBUG);
47 }
48
49 }