final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
LoggerRepository repository = this.repository.get(ccl == null ? NO_CCL_CLASSLOADER : ccl.hashCode());
if (repository == null)
{
final RootLogger root = new RootLogger(Level.INFO);
repository = new Hierarchy(root);
try
{
ConfigWatchDog configWatchDog = null;
if (ccl instanceof MuleApplicationClassLoader)
{
MuleApplicationClassLoader muleCL = (MuleApplicationClassLoader) ccl;
// check if there's an app-specific logging configuration available,
// scope the lookup to this classloader only, as getResource() will delegate to parents
// locate xml config first, fallback to properties format if not found
URL appLogConfig = muleCL.findResource("log4j.xml");
if (appLogConfig == null)
{
appLogConfig = muleCL.findResource("log4j.properties");
}
final String appName = muleCL.getAppName();
if (appLogConfig == null)
{
// fallback to defaults
String logName = String.format("mule-app-%s.log", appName);
File logDir = new File(MuleContainerBootstrapUtils.getMuleHome(), "logs");
File logFile = new File(logDir, logName);
DailyRollingFileAppender fileAppender = new DailyRollingFileAppender(new PatternLayout(PATTERN_LAYOUT), logFile.getAbsolutePath(), "'.'yyyy-MM-dd");
fileAppender.setAppend(true);
fileAppender.activateOptions();
root.addAppender(fileAppender);
}
else
{
configureFrom(appLogConfig, repository);
if (appLogConfig.toExternalForm().startsWith("file:"))