6
6
import org .apache .logging .log4j .core .impl .ContextAnchor ;
7
7
import org .apache .logging .log4j .core .selector .ContextSelector ;
8
8
9
- import java .io .IOException ;
10
9
import java .io .InputStream ;
11
10
import java .net .URI ;
12
11
import java .util .ArrayList ;
@@ -20,20 +19,17 @@ public class AndroidContextSelector implements ContextSelector {
20
19
21
20
private static final LoggerContext CONTEXT = new LoggerContext ("Default" );
22
21
23
- // private static boolean isStarted = false;
24
-
25
22
private void start (LoggerContext context ) {
26
23
InputStream stream = AndroidLog4jHelper .getConfig ();
27
24
28
- ConfigurationSource source = null ;
29
25
try {
30
- source = new ConfigurationSource (stream );
31
- } catch (IOException e ) {
26
+ ConfigurationSource source = new ConfigurationSource (stream );
27
+ Configuration config = org .apache .logging .log4j .core .config .xml .XmlConfigurationFactory .getInstance ()
28
+ .getConfiguration (source );
29
+ context .start (config );
30
+ } catch (Exception e ) {
32
31
e .printStackTrace ();
33
32
}
34
- Configuration config = org .apache .logging .log4j .core .config .xml .XmlConfigurationFactory .getInstance ()
35
- .getConfiguration (source );
36
- context .start (config );
37
33
}
38
34
39
35
public LoggerContext getContext (String fqcn , ClassLoader loader , boolean currentContext ) {
@@ -53,21 +49,14 @@ public LoggerContext getContext(final String fqcn, final ClassLoader loader, fin
53
49
return ctx != null ? ctx : CONTEXT ;
54
50
}
55
51
56
- public LoggerContext locateContext (final String name , final String configLocation ) {
57
- if (!CONTEXT .isStarted ()) {
58
- start (CONTEXT );
59
- }
60
- return CONTEXT ;
61
- }
62
-
63
52
public void removeContext (final LoggerContext context ) {
64
53
}
65
54
66
55
public List <LoggerContext > getLoggerContexts () {
67
56
if (!CONTEXT .isStarted ()) {
68
57
start (CONTEXT );
69
58
}
70
- final List <LoggerContext > list = new ArrayList <LoggerContext >();
59
+ final List <LoggerContext > list = new ArrayList <>();
71
60
list .add (CONTEXT );
72
61
return Collections .unmodifiableList (list );
73
62
}
0 commit comments