Re: dynamic logging control
Ralph Goers <[email protected]> Tue, 8 Nov 2016 07:54:44 -0700
| Newsgroups | gmane.comp.apache.logging |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_E1FE0D1F-6326-412C-826B-1984E1E75E79 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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 declared as a dependency in log4j-core. Ralph > On Nov 8, 2016, at 7:46 AM, Benson Margulies <[email protected]> = wrote: >=20 > ElementTraversal >=20 > On Nov 8, 2016 9:34 AM, "Ralph Goers" <[email protected] = <mailto:[email protected]>> wrote: > What is xml-apis required for? If you need it then we have a problem. >=20 > Ralph >=20 > > On Nov 8, 2016, at 7:13 AM, Benson Margulies <[email protected] = <mailto:[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] <mailto:[email protected]>> wrote: > >> I read http://logging.apache.org/log4j/2.x/manual/migration.html = <http://logging.apache.org/log4j/2.x/manual/migration.html> which > >> 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] <mailto:[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(false); > >>> 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] <mailto:[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? > >>>> > >>> > >>> > > >=20 >=20 --Apple-Mail=_E1FE0D1F-6326-412C-826B-1984E1E75E79 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = class=3D""><div class=3D"">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 declared as a = dependency in log4j-core.</div><div class=3D""><br class=3D""></div><div = class=3D"">Ralph</div><br class=3D""><div><blockquote type=3D"cite" = class=3D""><div class=3D"">On Nov 8, 2016, at 7:46 AM, Benson Margulies = <<a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""><p dir=3D"ltr" = class=3D"">ElementTraversal<br class=3D""> </p> <div class=3D"gmail_extra"><br class=3D""><div class=3D"gmail_quote">On = Nov 8, 2016 9:34 AM, "Ralph Goers" <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br = type=3D"attribution" class=3D""><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc = solid;padding-left:1ex">What is xml-apis required for? If you need it = then we have a problem.<br class=3D""> <br class=3D""> Ralph<br class=3D""> <br class=3D""> > On Nov 8, 2016, at 7:13 AM, Benson Margulies <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br class=3D""> ><br class=3D""> > The need to add xml-apis to the dependency tree was also a bit of a = surprise.<br class=3D""> ><br class=3D""> ><br class=3D""> > On Tue, Nov 8, 2016 at 9:10 AM, Benson Margulies <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br class=3D""> >> I read <a = href=3D"http://logging.apache.org/log4j/2.x/manual/migration.html" = rel=3D"noreferrer" target=3D"_blank" = class=3D"">http://logging.apache.org/<wbr = class=3D"">log4j/2.x/manual/migration.<wbr class=3D"">html</a> which<br = class=3D""> >> is how I got into the neighborhood of<br class=3D""> >><br class=3D""> >> org.apache.logging.log4j.core.<wbr = class=3D"">config.Configurator.setLevel<br class=3D""> >><br class=3D""> >> I can follow your recipe instead.<br class=3D""> >><br class=3D""> >><br class=3D""> >><br class=3D""> >> On Tue, Nov 8, 2016 at 9:05 AM, Ralph Goers <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br class=3D""> >>> Are you looking at the Logger or LoggerConfig. Log4j = 2 separates Loggers from their configuration.<br class=3D""> >>><br class=3D""> >>> To modify a logLevel you need to do:<br class=3D""> >>><br class=3D""> >>> LoggerContext context =3D (LoggerContext) = LogManager.getContext(false);<br class=3D""> >>> Configuration config =3D context.getConfiguration();<br = class=3D""> >>> LoggerConfig loggerConfig =3D config.getLoggerConfig(<wbr = class=3D"">loggerName);<br class=3D""> >>> loggerConfig.setLevel(level);<br class=3D""> >>> context.updateLoggers();<br class=3D""> >>><br class=3D""> >>> This process locates the configured Logger for the desired = logger name, sets its level and then modifies all the Loggers that use = the LoggerConfig.<br class=3D""> >>><br class=3D""> >>> Ralph<br class=3D""> >>><br class=3D""> >>>> On Nov 8, 2016, at 6:51 AM, Benson Margulies <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br class=3D""> >>>><br class=3D""> >>>> In old log4j, I've maintained a JUnit rule that = temporarily throttles a logger.<br class=3D""> >>>><br class=3D""> >>>> In log4j2, I see a setLevel, but no getLevel, which = rather screws up<br class=3D""> >>>> 'temporarily'.<br class=3D""> >>>><br class=3D""> >>>> What am I missing?<br class=3D""> >>>><br class=3D""> >>><br class=3D""> >>><br class=3D""> ><br class=3D""> <br class=3D""> <br class=3D""> </blockquote></div></div> </div></blockquote></div><br class=3D""></body></html>= --Apple-Mail=_E1FE0D1F-6326-412C-826B-1984E1E75E79--