1 package com.aragost.javahg.log;
2
3 import com.aragost.javahg.internals.ServiceLoader;
4 import com.google.common.base.Strings;
5
6
7
8
9
10
11
12 public abstract class LoggerFactory {
13
14 private static LoggerFactory instance;
15
16 static {
17 String loggerFactoryName = System.getProperty( LoggerFactory.class.getName() );
18 try
19 {
20 if ( ! Strings.isNullOrEmpty(loggerFactoryName) ){
21 instance = (LoggerFactory) Class.forName(loggerFactoryName).newInstance();
22 } else {
23 instance = ServiceLoader.loadService(LoggerFactory.class);
24 }
25 }
26 catch (Exception ex)
27 {
28
29 }
30 if ( instance == null ){
31 instance = new JULLoggerFactory();
32 }
33 }
34
35
36
37
38
39
40
41 public static Logger getLogger(Class<?> cls) {
42 return instance.getLoggerInstance(cls);
43 }
44
45 protected abstract Logger getLoggerInstance(Class<?> cls);
46
47 }