01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla;
14:
15: import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
16: import org.apache.avalon.excalibur.logger.LoggerManager;
17: import org.apache.avalon.framework.configuration.Configuration;
18: import org.apache.avalon.framework.container.ContainerUtil;
19: import org.apache.avalon.framework.context.DefaultContext;
20: import org.apache.avalon.framework.logger.Logger;
21: import org.rapla.components.util.IOUtil;
22: import org.rapla.framework.RaplaException;
23: import org.rapla.framework.StartupEnvironment;
24: import org.rapla.framework.internal.LogManagerAdapter;
25:
26: class RaplaLogKitAdapater implements LogManagerAdapter {
27:
28: LoggerManager m_loggerManager;
29:
30: public RaplaLogKitAdapater(StartupEnvironment env,
31: Configuration loggerConfig) throws RaplaException {
32: try {
33: final String lmLoggerName = loggerConfig.getAttribute(
34: "logger", "system.logkit");
35: m_loggerManager = new LogKitLoggerManager("rapla",
36: lmLoggerName);
37: DefaultContext context = new DefaultContext();
38: context.put("context-root", IOUtil.getFileFrom(env
39: .getContextRootURL()));
40: ContainerUtil.enableLogging(m_loggerManager, env
41: .getBootstrapLogger());
42: ContainerUtil.contextualize(m_loggerManager, context);
43: ContainerUtil.configure(m_loggerManager, loggerConfig);
44: } catch (Exception ex) {
45: throw new RaplaException(ex);
46: }
47:
48: }
49:
50: public Logger getLoggerForCategory(String categoryName) {
51: return m_loggerManager.getLoggerForCategory(categoryName);
52: }
53:
54: public Logger getDefaultLogger() {
55: return m_loggerManager.getDefaultLogger();
56: }
57:
58: }
|