3030package uk .ac .stfc .isis .ibex .logger .config ;
3131
3232import java .io .Serializable ;
33+ import java .net .URI ;
34+
3335import org .apache .logging .log4j .Level ;
3436import org .apache .logging .log4j .core .Appender ;
3537import org .apache .logging .log4j .core .Layout ;
4547import org .apache .logging .log4j .core .config .ConfigurationFactory ;
4648import org .apache .logging .log4j .core .config .ConfigurationSource ;
4749import org .apache .logging .log4j .core .config .DefaultConfiguration ;
50+ import org .apache .logging .log4j .core .config .Order ;
51+ import org .apache .logging .log4j .core .config .plugins .Plugin ;
4852import org .apache .logging .log4j .core .layout .PatternLayout ;
4953import org .eclipse .jface .preference .IPreferenceStore ;
5054
@@ -56,19 +60,41 @@ public final class LoggingConfiguration {
5660 private LoggingConfiguration () { }
5761
5862 public static void configure () {
59- System .setProperty ("log4j.configurationFactory" , Log4j2ConfigurationFactory .class .getName ());
63+ Log4j2ConfigurationFactory factory = new Log4j2ConfigurationFactory ();
64+ ConfigurationFactory .setConfigurationFactory (factory );
6065 }
6166
67+ /**
68+ * Configuration factory for Log4j2.
69+ * see https://logging.apache.org/log4j/2.x/manual/customconfig.html for details of how to configure this.
70+ *
71+ */
72+ @ Plugin (name = "Log4j2ConfigurationFactory" , category = ConfigurationFactory .CATEGORY )
73+ @ Order (50 )
6274 public static class Log4j2ConfigurationFactory extends ConfigurationFactory {
6375
76+ /**
77+ * {@inheritDoc}
78+ */
6479 @ Override
65- public Configuration getConfiguration (LoggerContext ignored , ConfigurationSource source ) {
80+ public Configuration getConfiguration (final LoggerContext ignored , final ConfigurationSource source ) {
6681 return new Log4j2Configuration ();
6782 }
6883
84+ /**
85+ * {@inheritDoc}
86+ */
87+ @ Override
88+ public Configuration getConfiguration (final LoggerContext ignored , final String name , final URI configLocation ) {
89+ return new Log4j2Configuration ();
90+ }
91+
92+ /**
93+ * {@inheritDoc}
94+ */
6995 @ Override
7096 protected String [] getSupportedTypes () {
71- return null ;
97+ return new String [] { "*" } ;
7298 }
7399 }
74100
0 commit comments