Re: dynamic logging control

Benson Margulies <[email protected]> Tue, 8 Nov 2016 10:50:40 -0500
Newsgroups gmane.comp.apache.logging
Message-ID <CALm0H57=AryVjr6Cm0htW1SmsDb=EpscXTspfiA3knZvGtAhpQ@mail.gmail.com>
I see. this particular thing has xerces in the classpath.


On Tue, Nov 8, 2016 at 10:49 AM, Benson Margulies <[email protected]> wr=
ote:
> Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142=
)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Sour=
ce)
> at org.apache.xerces.xinclude.XIncludeHandler.startDocument(Unknown Sourc=
e)
> at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Sourc=
e)
> at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Sour=
ce)
> at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
> at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlCo=
nfiguration.java:96)
> at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getCo=
nfiguration(XmlConfigurationFactory.java:46)
> at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getC=
onfiguration(ConfigurationFactory.java:519)
> at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getC=
onfiguration(ConfigurationFactory.java:455)
> at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfigura=
tion(ConfigurationFactory.java:265)
> at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.=
java:599)
> at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.=
java:620)
> at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:2=
26)
> at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4=
jContextFactory.java:242)
> at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4=
jContextFactory.java:45)
>
> On Tue, Nov 8, 2016 at 9:54 AM, Ralph Goers <[email protected]> =
wrote:
>> I=E2=80=99m not sure I understand. ElementTraversal is not a class so I =
am assuming
>> you mean it as a generic concept?  Do you know where we are traversing
>> elements and require xml-apis?  Also, I don=E2=80=99t see xml-apis decla=
red as a
>> dependency in log4j-core.
>>
>> Ralph
>>
>> On Nov 8, 2016, at 7:46 AM, Benson Margulies <[email protected]> wrot=
e:
>>
>> ElementTraversal
>>
>>
>> On Nov 8, 2016 9:34 AM, "Ralph Goers" <[email protected]> wrote=
:
>>>
>>> What is xml-apis required for? If you need it then we have a problem.
>>>
>>> Ralph
>>>
>>> > On Nov 8, 2016, at 7:13 AM, Benson Margulies <[email protected]>
>>> > wrote:
>>> >
>>> > The need to add xml-apis to the dependency tree was also a bit of a
>>> > surprise.
>>> >
>>> >
>>> > On Tue, Nov 8, 2016 at 9:10 AM, Benson Margulies <[email protected]=
m>
>>> > wrote:
>>> >> I read http://logging.apache.org/log4j/2.x/manual/migration.html whi=
ch
>>> >> is how I got into the neighborhood of
>>> >>
>>> >> org.apache.logging.log4j.core.config.Configurator.setLevel
>>> >>
>>> >> I can follow your recipe instead.
>>> >>
>>> >>
>>> >>
>>> >> On Tue, Nov 8, 2016 at 9:05 AM, Ralph Goers
>>> >> <[email protected]> wrote:
>>> >>> Are you looking at the Logger or LoggerConfig.  Log4j 2 separates
>>> >>> Loggers from their configuration.
>>> >>>
>>> >>> To modify a logLevel you need to do:
>>> >>>
>>> >>> LoggerContext context =3D (LoggerContext) LogManager.getContext(fal=
se);
>>> >>> Configuration config =3D context.getConfiguration();
>>> >>> LoggerConfig loggerConfig =3D config.getLoggerConfig(loggerName);
>>> >>> loggerConfig.setLevel(level);
>>> >>> context.updateLoggers();
>>> >>>
>>> >>> This process locates the configured Logger for the desired logger
>>> >>> name, sets its level and then modifies all the Loggers that use the
>>> >>> LoggerConfig.
>>> >>>
>>> >>> Ralph
>>> >>>
>>> >>>> On Nov 8, 2016, at 6:51 AM, Benson Margulies <[email protected]=
>
>>> >>>> wrote:
>>> >>>>
>>> >>>> In old log4j, I've  maintained a JUnit rule that temporarily
>>> >>>> throttles a logger.
>>> >>>>
>>> >>>> In log4j2, I see a setLevel, but no getLevel, which rather screws =
up
>>> >>>> 'temporarily'.
>>> >>>>
>>> >>>> What am I missing?
>>> >>>>
>>> >>>
>>> >>>
>>> >
>>>
>>>
>>