1 package org.slf4j.ext;
2
3 import org.slf4j.LoggerFactory;
4
5 /**
6 *
7 * This class is essentially a wrapper around an
8 * {@link LoggerFactory} producing {@link XLogger} instances.
9 *
10 * <p>Contrary to {@link LoggerFactory#getLogger(String)} method of
11 * {@link LoggerFactory}, each call to {@link getXLogger}
12 * produces a new instance of XLogger. This should not matter because an
13 * XLogger instance does not have any state beyond that of the Logger instance
14 * it wraps.
15 *
16 * @author Ralph Goers
17 * @author Ceki Gülcü
18 */
19 public class XLoggerFactory {
20
21 /**
22 * Get an XLogger instance by name.
23 *
24 * @param name
25 * @return
26 */
27 public static XLogger getXLogger(String name) {
28 return new XLogger(LoggerFactory.getLogger(name));
29 }
30
31 /**
32 * Get a new XLogger instance by class. The returned XLogger
33 * will be named after the class.
34 *
35 * @param clazz
36 * @return
37 */
38 @SuppressWarnings("unchecked")
39 public static XLogger getXLogger(Class clazz) {
40 return getXLogger(clazz.getName());
41 }
42 }