Obtaining logger list

Hello Logback users, I'm trying to migrate from log4j, more specifically to find a replacement for org.apache.log4j.LogManager.getCurrentLoggers Is there any other way to obtain Logger list except through JMX and JMXConfigurator? Accessing LoggerContext would be enough too - how does one grab a hold of that one? I see ContextAware interface and Base implementation, maybe if my custom class would implement/extend these I could get LoggerContext, but how do I register my components with Logback to have the LoggerContext injected? Regards, Stevo.

Hi Stevo, Assuming logback is the current slf4j binding: import org.slf4j.LoggerFactory; import ch.qos.logback.classic.LoggerContext; LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); The LoggerContext class has a method called getLoggerList() which returns the data you are asking for. Does this answer your question? -- Ceki On 13/10/2011 11:49 AM, Stevo Slavić wrote:
Hello Logback users,
I'm trying to migrate from log4j, more specifically to find a replacement for org.apache.log4j.LogManager.getCurrentLoggers
Is there any other way to obtain Logger list except through JMX and JMXConfigurator? Accessing LoggerContext would be enough too - how does one grab a hold of that one? I see ContextAware interface and Base implementation, maybe if my custom class would implement/extend these I could get LoggerContext, but how do I register my components with Logback to have the LoggerContext injected?
Regards, Stevo.

Yes, this was what I needed. Now I understand the relationship between slf4j ILoggerFactory and logback LoggerContext. Ceki, thank you very much! Regards, Stevo. On Thu, Oct 13, 2011 at 12:01 PM, ceki <ceki@qos.ch> wrote:
Hi Stevo,
Assuming logback is the current slf4j binding:
import org.slf4j.LoggerFactory; import ch.qos.logback.classic.LoggerContext;
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
The LoggerContext class has a method called getLoggerList() which returns the data you are asking for.
Does this answer your question? -- Ceki
On 13/10/2011 11:49 AM, Stevo Slavić wrote:
Hello Logback users,
I'm trying to migrate from log4j, more specifically to find a replacement for org.apache.log4j.LogManager.getCurrentLoggers
Is there any other way to obtain Logger list except through JMX and JMXConfigurator? Accessing LoggerContext would be enough too - how does one grab a hold of that one? I see ContextAware interface and Base implementation, maybe if my custom class would implement/extend these I could get LoggerContext, but how do I register my components with Logback to have the LoggerContext injected?
Regards, Stevo.
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Hello, I want to add some functions to Logger with specific level (user level) can we create our Levels ? how ? Thanks

Please see the manual, chapter 2: http://logback.qos.ch/manual/architecture.html It says, "Note that in logback, the Level class is final and cannot be sub-classed, as a much more flexible approach exists in the form of Markerobjects." Paul On Mon, Oct 17, 2011 at 11:13 AM, BAKHTI Mohammed <onlymed@hotmail.com>wrote:
Hello,
I want to add some functions to Logger with specific level (user level) can we create our Levels ? how ?
Thanks
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (4)
-
BAKHTI Mohammed
-
ceki
-
Paul Gifford
-
Stevo Slavić