-
1. Re: Using log4j on JBossAS7 - log category enumeration
jamezp Nov 23, 2011 1:01 PM (in response to tc7)1 of 1 people found this helpfulJust so you know we are working on better support for log4j emulation with JBoss AS 7.While that does you no good now, I do have a work-around for you. It's not quite as elegant as log.getLoggerRepostory(), but it should work.import java.util.List; import org.jboss.logmanager.LogContext; public class LoggerNames { public static List<String> get() { return LogContext.getLogContext().getLoggingMXBean().getLoggerNames(); } }
-
2. Re: Using log4j on JBossAS7 - log category enumeration
tc7 Nov 23, 2011 10:52 PM (in response to jamezp)Thanks James, that's a workable workaround.
I've used the above to create a method to return a list of log4j loggers (albeit JBoss specific code):
import org.apache.log4j.Logger;
import org.jboss.logmanager.LogContext;
public List<Logger> getLog4jLoggers()
{
LogContext cxt = LogContext.getLogContext();
List<String> names = cxt.getLoggingMXBean().getLoggerNames();
List<Logger> loggers = new ArrayList<Logger>(names.size());
for (String loggerName : names)
{
Logger logger = Logger.getLogger(loggerName);
if (logger != null)
{
loggers.add(logger);
}
else
{
log.warn("Could not find log4j logger with name ["+loggerName+"].");
}
}
return loggers;
}