Re: dynamic logging control

Benson Margulies <[email protected]> Tue, 8 Nov 2016 10:49:13 -0500
Newsgroups gmane.comp.apache.logging
Message-ID <CALm0H55WNL1x+ybWVTOmPXqHRqnsXD0pNMVfR7qzK1sZRC02KA@mail.gmail.com>
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 Source=
)
at org.apache.xerces.xinclude.XIncludeHandler.startDocument(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source=
)
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>(XmlConf=
iguration.java:96)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConf=
iguration(XmlConfigurationFactory.java:46)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getCon=
figuration(ConfigurationFactory.java:519)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getCon=
figuration(ConfigurationFactory.java:455)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfigurati=
on(ConfigurationFactory.java:265)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.ja=
va:599)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.ja=
va:620)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226=
)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jC=
ontextFactory.java:242)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jC=
ontextFactory.java:45)

On Tue, Nov 8, 2016 at 9:54 AM, Ralph Goers <[email protected]> wr=
ote:
> I=E2=80=99m not sure I understand. ElementTraversal is not a class so I a=
m 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 declar=
ed as a
> dependency in log4j-core.
>
> Ralph
>
> On Nov 8, 2016, at 7:46 AM, Benson Margulies <[email protected]> wrote=
:
>
> 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]=
>
>> > wrote:
>> >> I read http://logging.apache.org/log4j/2.x/manual/migration.html whic=
h
>> >> 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(fals=
e);
>> >>> 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 u=
p
>> >>>> 'temporarily'.
>> >>>>
>> >>>> What am I missing?
>> >>>>
>> >>>
>> >>>
>> >
>>
>>
>