Programmatically determine if logger is "OFF"

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatically determine if logger is "OFF"

COHEN, STEVEN M
"OFF" is a level usable in a logging configuration file.  I have a need to see if a logger is configured this way.  There is no API in logger that checks this.  There is a workaround of course - if isFatalEnabled() returns false, then the logger is OFF.  But it would be trivial to add an isOff() method and a good thing to have it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programmatically determine if logger is "OFF"

Gary Gregory-4
The best way to get this cooking is to create a JIRA and attach a patch.

Note that It's not just adding an isOff() method, there is also the various
implementations. You'll also have to add unit tests. Also, should there be
an isOff(Marker)?

There is also the ALL level...

Gary

On Thu, Mar 30, 2017 at 9:08 AM, COHEN, STEVEN M <[hidden email]> wrote:

> "OFF" is a level usable in a logging configuration file.  I have a need to
> see if a logger is configured this way.  There is no API in logger that
> checks this.  There is a workaround of course - if isFatalEnabled() returns
> false, then the logger is OFF.  But it would be trivial to add an isOff()
> method and a good thing to have it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
E-Mail: [hidden email] | [hidden email]
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically determine if logger is "OFF"

Remko Popma-2
I think Gary rightly points out that this may not be as trivial as it seems. Personally I am not a fan of API changes to add convenience methods.  

Remko

Sent from my iPhone

> On Mar 31, 2017, at 8:20, Gary Gregory <[hidden email]> wrote:
>
> The best way to get this cooking is to create a JIRA and attach a patch.
>
> Note that It's not just adding an isOff() method, there is also the various
> implementations. You'll also have to add unit tests. Also, should there be
> an isOff(Marker)?
>
> There is also the ALL level...
>
> Gary
>
>> On Thu, Mar 30, 2017 at 9:08 AM, COHEN, STEVEN M <[hidden email]> wrote:
>>
>> "OFF" is a level usable in a logging configuration file.  I have a need to
>> see if a logger is configured this way.  There is no API in logger that
>> checks this.  There is a workaround of course - if isFatalEnabled() returns
>> false, then the logger is OFF.  But it would be trivial to add an isOff()
>> method and a good thing to have it.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> --
> E-Mail: [hidden email] | [hidden email]
> Java Persistence with Hibernate, Second Edition
> <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
> JUnit in Action, Second Edition
> <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
> Spring Batch in Action
> <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programmatically determine if logger is "OFF"

Gary Gregory-4
I am OK with adding these methods (isOff(), isAll()), I only wanted to
point out that this is not just one method.

Gary

On Thu, Mar 30, 2017 at 5:42 PM, Remko Popma <[hidden email]> wrote:

> I think Gary rightly points out that this may not be as trivial as it
> seems. Personally I am not a fan of API changes to add convenience methods.
>
> Remko
>
> Sent from my iPhone
>
> > On Mar 31, 2017, at 8:20, Gary Gregory <[hidden email]> wrote:
> >
> > The best way to get this cooking is to create a JIRA and attach a patch.
> >
> > Note that It's not just adding an isOff() method, there is also the
> various
> > implementations. You'll also have to add unit tests. Also, should there
> be
> > an isOff(Marker)?
> >
> > There is also the ALL level...
> >
> > Gary
> >
> >> On Thu, Mar 30, 2017 at 9:08 AM, COHEN, STEVEN M <[hidden email]>
> wrote:
> >>
> >> "OFF" is a level usable in a logging configuration file.  I have a need
> to
> >> see if a logger is configured this way.  There is no API in logger that
> >> checks this.  There is a workaround of course - if isFatalEnabled()
> returns
> >> false, then the logger is OFF.  But it would be trivial to add an
> isOff()
> >> method and a good thing to have it.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
> >
> > --
> > E-Mail: [hidden email] | [hidden email]
> > Java Persistence with Hibernate, Second Edition
> > <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
> >
> > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1617290459>
> > JUnit in Action, Second Edition
> > <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22
> >
> >
> > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182021>
> > Spring Batch in Action
> > <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182951>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
E-Mail: [hidden email] | [hidden email]
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Reply | Threaded
Open this post in threaded view
|

Re: Programmatically determine if logger is "OFF"

Matt Sicker
Can't you just use isEnabled(Level.OFF)?

On 30 March 2017 at 20:17, Gary Gregory <[hidden email]> wrote:

> I am OK with adding these methods (isOff(), isAll()), I only wanted to
> point out that this is not just one method.
>
> Gary
>
> On Thu, Mar 30, 2017 at 5:42 PM, Remko Popma <[hidden email]>
> wrote:
>
> > I think Gary rightly points out that this may not be as trivial as it
> > seems. Personally I am not a fan of API changes to add convenience
> methods.
> >
> > Remko
> >
> > Sent from my iPhone
> >
> > > On Mar 31, 2017, at 8:20, Gary Gregory <[hidden email]> wrote:
> > >
> > > The best way to get this cooking is to create a JIRA and attach a
> patch.
> > >
> > > Note that It's not just adding an isOff() method, there is also the
> > various
> > > implementations. You'll also have to add unit tests. Also, should there
> > be
> > > an isOff(Marker)?
> > >
> > > There is also the ALL level...
> > >
> > > Gary
> > >
> > >> On Thu, Mar 30, 2017 at 9:08 AM, COHEN, STEVEN M <[hidden email]>
> > wrote:
> > >>
> > >> "OFF" is a level usable in a logging configuration file.  I have a
> need
> > to
> > >> see if a logger is configured this way.  There is no API in logger
> that
> > >> checks this.  There is a workaround of course - if isFatalEnabled()
> > returns
> > >> false, then the logger is OFF.  But it would be trivial to add an
> > isOff()
> > >> method and a good thing to have it.
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [hidden email]
> > >> For additional commands, e-mail: [hidden email]
> > >>
> > >>
> > >
> > >
> > > --
> > > E-Mail: [hidden email] | [hidden email]
> > > Java Persistence with Hibernate, Second Edition
> > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> > linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
> > >
> > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > 1617290459>
> > > JUnit in Action, Second Edition
> > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> > linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de4
> 18%22
> > >
> > >
> > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > 1935182021>
> > > Spring Batch in Action
> > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> > 1935182951>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> E-Mail: [hidden email] | [hidden email]
> Java Persistence with Hibernate, Second Edition
> <https://www.amazon.com/gp/product/1617290459/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&
> linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1617290459>
> JUnit in Action, Second Edition
> <https://www.amazon.com/gp/product/1935182021/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&
> linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22
> >
>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182021>
> Spring Batch in Action
> <https://www.amazon.com/gp/product/1935182951/ref=as_li_
> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&
> linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%
> 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=
> 1935182951>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



--
Matt Sicker <[hidden email]>