001: /*
002: * $Id: GWDebug.java,v 1.8 2006/07/28 02:56:34 portalbld Exp $
003: * $Source: /m/portal/ps/srap/src/com/sun/portal/util/GWDebug.java,v $
004: * $Log: GWDebug.java,v $
005: * Revision 1.8 2006/07/28 02:56:34 portalbld
006: * >> Collating checkins between 2006/06/21 and 2006/07/11 which were lost due to a cvs server crash
007: * >> revision 1.8
008: * >> date: 2006/06/29 20:54:24; author: vk162573; state: Exp; lines: +5 -2
009: * >> changes for supporting windows & hpux CRT 6440853
010: *
011: * Revision 1.8 2006/06/29 20:54:24 vk162573
012: * changes for supporting windows & hpux CRT 6440853
013: *
014: * Revision 1.7 2005/12/06 12:16:12 ss150821
015: * 6349604 - SUNWportal<rwproxyinstancename> directory in /var/opt should be removed
016: *
017: * Revision 1.6 2005/11/30 11:28:15 ss150821
018: * 6356996 - Srap Code base needs to save files in the unix file format and not windows
019: *
020: * Revision 1.5 2005/05/10 10:21:04 ss150821
021: * CR - 6267171 Created P1 portalserver/erproxy PS 7.0: Gateway becomes slow and the security ceritificate is not getting displayed in the browser
022: *
023: * Revision 1.4 2005/02/23 11:39:12 ss150821
024: * RFE 6223490 - SRA Should use JDK based logging
025: *
026: * Revision 1.3 2005/02/21 08:03:15 ss150821
027: * 6223490 - JDK Logging move for SRA
028: *
029: * Revision 1.2 2005/02/17 08:27:37 ss150821
030: * RFE 6223490 - Add JDK Logging Support to SRA
031: *
032: * Revision 1.1 2002/06/14 09:04:22 rt130506
033: * SRAP rebranding
034: *
035: * Revision 1.4 2002/06/11 16:02:12 bv131302
036: * new branded
037: *
038: * Revision 1.3 2002/03/18 10:19:28 mm132998
039: * Bug ID : # 4653988 CRT : # 574 Desc : Lihue PRD 7.4.4.1 and requirements for Bug 4195483
040: *
041: *
042: */
043: /*
044: * @(#)GWDebug.java 1.2 00/02/02
045: *
046: * Copyright (c) 02/02/00 Sun Microsystems, Inc. All Rights Reserved.
047: */
048:
049: package com.sun.portal.util;
050:
051: import java.io.File;
052: import java.io.FileNotFoundException;
053: import java.io.FileOutputStream;
054: import java.io.PrintStream;
055: import java.util.logging.Level;
056: import java.util.logging.Logger;
057:
058: import com.sun.portal.log.common.PortalLogger;
059:
060: public class GWDebug {
061: public static Debug debug;
062: private static Logger logger = PortalLogger
063: .getLogger(GWDebug.class);
064:
065: public static void createDefault(String name) {
066: // String fullName = name + "."+ System.getProperty("conf.suffix", "");
067: String conf = System.getProperty("conf.suffix", "");
068: String fullName = null;
069: if (conf.length() == 0) {
070: fullName = name;
071: } else {
072: fullName = name + "." + conf;
073: }
074: debug = new Debug(fullName);
075: debug.setDebug();
076: createDebugLogs(name.replaceFirst("srap", "").toLowerCase());
077: }
078:
079: private static void createDebugLogs(String component) {
080: String logFilePattern = ""
081: + SystemProperties
082: .get("debug.com.sun.portal.handler.java.util.logging.FileHandler.pattern");
083: String fs = "/";
084: String debugFile = logFilePattern.substring(0, logFilePattern
085: .lastIndexOf(fs))
086: + fs + component + ".debug";
087:
088: try {
089: System.setOut(new PrintStream(new FileOutputStream(
090: new File(debugFile), true)));
091: System.setErr(new PrintStream(new FileOutputStream(
092: new File(debugFile), true)));
093: } catch (FileNotFoundException e) {
094: logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX013", e);
095: }
096: }
097:
098: public static Debug createDebugLog(String name) {
099: // String fullName = name + "."+ System.getProperty("conf.suffix", "");
100: String conf = System.getProperty("conf.suffix", "");
101: String fullName = null;
102: if (conf.length() == 0) {
103: fullName = name;
104: } else {
105: fullName = name + "." + conf;
106: }
107: return Debug.getInstance(fullName);
108: }
109: }
|