I have written this custom configuration factory extended class to use log4j2 without a configuration file while I have been waiting on replies here and stack overflow....
according to
ConfigurationSource API, I believe passing null as the configuration source means that there will be no "real" configuration file, aka do everything programatically...
after I have these methods writtin, the createConfiguration, and getConfiguration, I am kind of confused on how to go about using this plugin/Configuration Factory to set up my log4j configuration.
According to
Apache Instructions, it says -
The below example overrides the getConfiguration() method to return a Configuration created by the ConfigurationBuilder. This will cause the Configuration to automatically be hooked into Log4j when the LoggerContext is created. In the example below, because it specifies a supported type of "*" it will override any configuration files provided.
I am not sure what it means by calling the getConfiguration method will cause the configuration to automatically be hooked into log4j when the LoggerContext is created? When is /should the LoggerContext be created? the getConfiguration method is asking for a LoggerContext as an input variable? Do I create a LoggerContext in my main class and pass it into this getConfiguration method and that will do the trick?
I dont really think so because looking at that code, the getConfiguration method asks for a LoggerContext input variable but then proceeds to not do anything with it at all?
Does anyone know how I use this to make log4j use this custom configuration builder instead of an xml file?