You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2014/03/24 03:16:53 UTC
Porting from 1.0 Logger.getLevel()
In order to see how practical 2.0 is going to be for our large app server
code base, I branched it a while back and I have been porting.
One of the things we do is Logger.getLevel(). This is no longer in the 2.0
API.
I looks like we can add it by filling in the blanks in
org.apache.logging.slf4j.SLF4JLogger.getLevel() with a hack like:
public Level getLevel() {
if (logger.isTraceEnabled()) {
return Level.TRACE;
}
if (logger.isDebugEnabled()) {
return Level.DEBUG;
}
if (logger.isInfoEnabled()) {
return Level.INFO;
}
if (logger.isWarnEnabled()) {
return Level.WARN;
}
if (logger.isErrorEnabled()) {
return Level.ERROR;
}
// Option: throw new IllegalStateException("Unknown SLF4JLevel");
// Option: return Level.ALL;
return Level.OFF;
}
Thoughts?
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: Porting from 1.0 Logger.getLevel()
Posted by Gary Gregory <ga...@gmail.com>.
See the patch in https://issues.apache.org/jira/browse/LOG4J2-576 which
contains other supporting code.
Gary
On Sun, Mar 23, 2014 at 10:16 PM, Gary Gregory <ga...@gmail.com>wrote:
> In order to see how practical 2.0 is going to be for our large app server
> code base, I branched it a while back and I have been porting.
>
> One of the things we do is Logger.getLevel(). This is no longer in the 2.0
> API.
>
> I looks like we can add it by filling in the blanks in
> org.apache.logging.slf4j.SLF4JLogger.getLevel() with a hack like:
>
> public Level getLevel() {
> if (logger.isTraceEnabled()) {
> return Level.TRACE;
> }
> if (logger.isDebugEnabled()) {
> return Level.DEBUG;
> }
> if (logger.isInfoEnabled()) {
> return Level.INFO;
> }
> if (logger.isWarnEnabled()) {
> return Level.WARN;
> }
> if (logger.isErrorEnabled()) {
> return Level.ERROR;
> }
> // Option: throw new IllegalStateException("Unknown SLF4JLevel");
> // Option: return Level.ALL;
> return Level.OFF;
> }
>
> Thoughts?
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: Porting from 1.0 Logger.getLevel()
Posted by Matt Sicker <bo...@gmail.com>.
+1 for getLevel but no setLevel.
On 23 March 2014 22:57, Ralph Goers <ra...@dslextreme.com> wrote:
> core.Logger has a getLevel method. I think we should add getLevel to
> Logger in the API. However, there should not be a setter.
>
> Ralph
>
> On Mar 23, 2014, at 7:16 PM, Gary Gregory <ga...@gmail.com> wrote:
>
> In order to see how practical 2.0 is going to be for our large app server
> code base, I branched it a while back and I have been porting.
>
> One of the things we do is Logger.getLevel(). This is no longer in the 2.0
> API.
>
> I looks like we can add it by filling in the blanks in
> org.apache.logging.slf4j.SLF4JLogger.getLevel() with a hack like:
>
> public Level getLevel() {
> if (logger.isTraceEnabled()) {
> return Level.TRACE;
> }
> if (logger.isDebugEnabled()) {
> return Level.DEBUG;
> }
> if (logger.isInfoEnabled()) {
> return Level.INFO;
> }
> if (logger.isWarnEnabled()) {
> return Level.WARN;
> }
> if (logger.isErrorEnabled()) {
> return Level.ERROR;
> }
> // Option: throw new IllegalStateException("Unknown SLF4JLevel");
> // Option: return Level.ALL;
> return Level.OFF;
> }
>
> Thoughts?
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
--
Matt Sicker <bo...@gmail.com>
Re: Porting from 1.0 Logger.getLevel()
Posted by Ralph Goers <ra...@dslextreme.com>.
core.Logger has a getLevel method. I think we should add getLevel to Logger in the API. However, there should not be a setter.
Ralph
On Mar 23, 2014, at 7:16 PM, Gary Gregory <ga...@gmail.com> wrote:
> In order to see how practical 2.0 is going to be for our large app server code base, I branched it a while back and I have been porting.
>
> One of the things we do is Logger.getLevel(). This is no longer in the 2.0 API.
>
> I looks like we can add it by filling in the blanks in org.apache.logging.slf4j.SLF4JLogger.getLevel() with a hack like:
>
> public Level getLevel() {
> if (logger.isTraceEnabled()) {
> return Level.TRACE;
> }
> if (logger.isDebugEnabled()) {
> return Level.DEBUG;
> }
> if (logger.isInfoEnabled()) {
> return Level.INFO;
> }
> if (logger.isWarnEnabled()) {
> return Level.WARN;
> }
> if (logger.isErrorEnabled()) {
> return Level.ERROR;
> }
> // Option: throw new IllegalStateException("Unknown SLF4JLevel");
> // Option: return Level.ALL;
> return Level.OFF;
> }
>
> Thoughts?
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory