Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

java - Number of loggers used

I'm working on a very large java application with log4j, and I was wondering if there is a way to extract in runtime the number of active loggers? Or what are the existing loggers in the application? My end goal is to get a list of all loggers and change their level in runtime. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could try something like:

Enumeration allLoggers = Logger.getRootLogger()
.getLoggerRepository()
.getCurrentLoggers();

Then iterate over allLoggers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...