servTarget.setFormatter(formatter);
Hierarchy.getDefaultHierarchy().setDefaultLogTarget(servTarget);
Hierarchy.getDefaultHierarchy().setDefaultPriority(logPriority);
final Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor("");
final DefaultLogKitManager logKitManager = new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
logKitManager.setLogger(logger);
final DefaultContext subcontext = new DefaultContext(this.appContext);
subcontext.put("servlet-context", this.servletContext);
if (this.servletContextPath == null) {
File logSCDir = new File(this.workDir, "log");
logSCDir.mkdirs();
if (logger.isWarnEnabled()) {
logger.warn("Setting servlet-context for LogKit to " + logSCDir);
}
subcontext.put("context-root", logSCDir.toString());
} else {
subcontext.put("context-root", this.servletContextPath);
}
try {
logKitManager.contextualize(subcontext);
this.logKitManager = logKitManager;
//Configure the logkit management
String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");
// test if this is a qualified url
InputStream is = null;
if ( logkitConfig.indexOf(':') == -1) {
is = this.servletContext.getResourceAsStream(logkitConfig);
if (is == null) is = new FileInputStream(logkitConfig);
} else {
URL logkitURL = new URL(logkitConfig);
is = logkitURL.openStream();
}
final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
final Configuration conf = builder.build(is);
logKitManager.configure(conf);
} catch (Exception e) {
Hierarchy.getDefaultHierarchy().log("Could not set up Cocoon Logger, will use screen instead", e);
}
if (accesslogger != null) {
this.log = logKitManager.getLogger(accesslogger);
} else {
this.log = logKitManager.getLogger("cocoon");
}
}