01: /**
02: * $Id: NetFileLogManager.java,v 1.14 2005/11/30 11:26:34 ss150821 Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.netfile.servlet.java1;
14:
15: import com.iplanet.log.LogManager;
16: import com.sun.portal.log.common.PortalLogger;
17: import com.iplanet.log.LogRecord;
18: import com.iplanet.log.LogException;
19: import com.iplanet.sso.SSOToken;
20:
21: import java.util.logging.*;
22:
23: public class NetFileLogManager {
24:
25: private static final String logFile = "srapNetFile";
26: private LogManager logMgr = null;
27: private static Logger logger = PortalLogger
28: .getLogger(NetFileLogManager.class);
29:
30: public NetFileLogManager(SSOToken token) throws Exception {
31: createLog(token);
32: }
33:
34: //-------------------------------------------------------------
35: // This method logs error messages
36: //-------------------------------------------------------------
37:
38: public void doError(String msg) {
39: if (logMgr == null)
40: return;
41: String suffix = ":Error - ";
42: LogRecord logrec = new LogRecord(logFile, suffix + msg);
43: try {
44: logMgr.write(logrec, logFile);
45: } catch (LogException le) {
46: // logger.log(Level.SEVERE, "doError - could not log message.", le);
47: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1133");
48: }
49: }
50:
51: //-------------------------------------------------------------
52: // This method logs successful events ( messages )
53: //-------------------------------------------------------------
54:
55: public void doLog(String msg) {
56: if (logMgr == null)
57: return;
58: try {
59: String suffix = ":Log - ";
60: LogRecord logrec = new LogRecord(logFile, suffix + msg);
61: try {
62: logMgr.write(logrec, logFile);
63: } catch (LogException le) {
64: // logger.log(Level.SEVERE, "doLog - could not log message.", le);
65: logger.log(Level.SEVERE, "PSSRNF_CSPNSJ1134");
66: }
67: } catch (Exception ex) {
68: }
69: }
70:
71: private void createLog(SSOToken ssoToken) throws Exception {
72: logMgr = new LogManager(ssoToken);
73: logMgr.create(logFile);
74: }
75: }
|