Doh! I thought you had provided me with the magic bullet. :) Ok. I'll back to programmically registering info read from my XmlConfiguration into the active Context.
On Fri, Feb 9, 2018 at 11:12 AM, Ralph Goers <ralph.go...@dslextreme.com> wrote: > It occurs to me that there is a problem with my suggest in that you cannot > create a new Configuration using the currently active configuration as that > will cause problems. The current configuration needs to be cloned. I don’t > know if we have an easy way to do that. > > Ralph > >> On Feb 9, 2018, at 9:08 AM, Ralph Goers <ralph.go...@dslextreme.com> wrote: >> >> If you want to add to their configuration then you should use a >> CompositeConfiguration. In that case I would get the current configuration, >> create your own Configuration, add them both to a new CompositeConfiguration >> and then call Configurator.initialize(compositeConfiguration). >> >> Ralph >> >>> On Feb 9, 2018, at 9:03 AM, Mike Kienenberger <mkien...@gmail.com> wrote: >>> >>> Thanks, Ralph, >>> >>> While that does work (tested) and could be useful in some instances, >>> it would require that we extract and keep synced the logging >>> configuration from EVIL.jar, then append our own changes to it. I can >>> see how this will be helpful when I'm doing development in this >>> environment. But it doesn't meet the need of only changing logging so >>> that our own module logs to a different location. >>> >>> On Thu, Feb 8, 2018 at 7:26 PM, Ralph Goers <ralph.go...@dslextreme.com> >>> wrote: >>>> If you want to replace the existing configuration you should be able to do: >>>> >>>> Configurator.initialize(“MyApp”, “app-log4j2.xml”); >>>> >>>> This will look for a file named app-log4j2.xml on the class path. >>>> >>>> Ralph >>>> >>>>> On Feb 8, 2018, at 1:28 PM, Mike Kienenberger <mkien...@gmail.com> wrote: >>>>> >>>>> As others have reported in years past, the examples in the docs for >>>>> >>>>> Programmatically Modifying the Current Configuration after Initialization >>>>> >>>>> are out of date. They don't compile. They don't work (affect the >>>>> existing logging) even if you do fix the errors. >>>>> >>>>> Here's my situation: >>>>> >>>>> I am working in an environment with EVIL.JAR which includes a log4j2.xml >>>>> file. >>>>> I can't change the jar. I can't specific a System Property to override >>>>> it. >>>>> >>>>> My code gets called as a loaded module long after the logging system >>>>> is initialized. >>>>> >>>>> I want logging in my own code to go to a different location, and >>>>> preferably I'd like to read the configuration in from a log4j2.xml >>>>> file so that anyone who uses my module isn't victim to the same evil >>>>> hardcoded-logging practices of EVIL.JAR. >>>>> >>>>> Creating an XMLConfiguration and initializing it lets me read the xml >>>>> file easily enough. Looping through the data gets me the Appenders, >>>>> Filters and Loggers. But I still can't use them to modify the >>>>> existing configuration. >>>>> >>>>> Another person took the approach of using JUL instead. I hate JUL and >>>>> I'd really rather not have to go down that route. >>>>> >>>>> Thanks in advance. >>>>> -Mike >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >>>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org >>>>> >>>>> >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >>> For additional commands, e-mail: log4j-user-h...@logging.apache.org >>> >>> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >> For additional commands, e-mail: log4j-user-h...@logging.apache.org >> >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org