01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.search.util;
07:
08: import com.sun.portal.log.common.PortalLogManager;
09:
10: import java.util.logging.Logger;
11: import java.io.*;
12:
13: /**
14: * Search file based logging
15: */
16: public class SearchLogger {
17:
18: static Logger rootLogger;
19: static Logger rdmRootLogger;
20:
21: private SearchLogger() {
22: }
23:
24: private static Logger initLogger(String rootLoggerName,
25: String serverRoot) {
26: PortalLogManager manager = new PortalLogManager();
27: String searchLogConfigFile = serverRoot + File.separator
28: + SearchConfig.CONFDIR + File.separator
29: + PortalLogManager.SEARCH_LOG_CONFIG_FILENAME;
30: manager.init(rootLoggerName, searchLogConfigFile);
31: return Logger.getLogger(rootLoggerName);
32: }
33:
34: private static Logger initDefaultLogger() {
35: PortalLogManager manager = new PortalLogManager();
36: manager.init(PortalLogManager.DEBUG_ROOT_LOGGER);
37: return Logger.getLogger(PortalLogManager.DEBUG_ROOT_LOGGER);
38: }
39:
40: /**
41: * Initializes the root logger. Invoked from RDMgr and RDMContext.
42: * RDMgr - rootLogger is debug.com.sun.portal.search.rdmgr
43: * filename is <server.root>/logs/rdmgr.0.0.log
44: * RDMContext - rootLogger is debug.com.sun.portal.search.rdmserver
45: * filename is <server.root>/logs/rdmserver.0.0.log
46: * @param rootLoggerName the name of the root logger
47: * @param serverRoot the server root
48: * @throws Exception
49: */
50: public static void init(String rootLoggerName, String serverRoot)
51: throws Exception {
52: rootLogger = initLogger(rootLoggerName, serverRoot);
53: if (rootLogger == null) {
54: throw new Exception("Invalid rootLogger:" + rootLoggerName);
55: }
56: }
57:
58: /**
59: * Initializes the root logger. Invoked from RDMContext.
60: * RDMContext - rootLogger is debug.com.sun.portal.search.rdm
61: * filename is <server.root>/logs/rdm.0.0.log
62: * @param rootLoggerName the name of the root logger
63: * @param serverRoot the server root
64: * @throws Exception
65: */
66: public static void rdmLogInit(String rootLoggerName,
67: String serverRoot) throws Exception {
68: rdmRootLogger = initLogger(rootLoggerName, serverRoot);
69: if (rdmRootLogger == null) {
70: throw new Exception("Invalid rootLogger:" + rootLoggerName);
71: }
72: }
73:
74: /**
75: * Returns the rootLogger which might be either
76: * "debug.com.sun.portal.search.rdmserver" or "debug.com.sun.portal.search.rdmgr"
77: * @return
78: */
79: public static Logger getLogger() {
80: if (rootLogger == null) {
81: rootLogger = initDefaultLogger();
82: }
83: return rootLogger;
84: }
85:
86: /**
87: * Returns the rootLogger which is "debug.com.sun.portal.search.rdm"
88: * @return
89: */
90: public static Logger getRDMLogger() {
91: if (rdmRootLogger == null) {
92: rdmRootLogger = initDefaultLogger();
93: }
94: return rdmRootLogger;
95: }
96: }
|