KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > logging > DeploymentAuditLogHandler


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.server.logging;
25
26 import com.sun.logging.LogDomains;
27 import java.util.logging.ErrorManager JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import java.util.logging.Logger JavaDoc;
30
31 /**
32  * Writes deployment audit records.
33  * <p>
34  * This class extends FileandSyslogHandler because it does nearly the same
35  * function, except to a separate deployment audit file.
36  */

37 public class DeploymentAuditLogHandler extends FileandSyslogHandler {
38     
39     private static final String JavaDoc CONFIGURED_LEVEL_PROPERTY_NAME = "com.sun.aas.deployment.audit.level";
40     private static final String JavaDoc CONFIGURED_LEVEL_PROPERTY_DEFAULT = "OFF";
41     
42     private static final DeploymentAuditLogHandler thisInstance =
43         new DeploymentAuditLogHandler( );
44
45     private String JavaDoc logFileName = "deployment.log";
46
47     public static synchronized DeploymentAuditLogHandler getInstance( ) {
48         return thisInstance;
49     }
50
51     /**
52      * Creates a new instance of DeploymentAuditLogHandler, bypassing
53      * logic in the superclass constructor that creates the AMXLoggingHook.
54      */

55     protected DeploymentAuditLogHandler() {
56     }
57     
58     protected AMXLoggingHook createAMXLoggingHook() {
59         return null;
60     }
61
62     protected String JavaDoc getLogFileName() {
63         return logFileName;
64     }
65     
66     /**
67      *Returns the logging Level setting for the deployment auditing logger.
68      *<p>
69      *This method uses a system property rather than a normal logging level
70      *setting from domain.xml to avoid changing the domain.xml layout (due to schedule issues).
71      *Later on this could be converted, time permitting.
72      *@return the logging Level to be used for deployment logging; default if OFF
73      */

74     public static Level JavaDoc getConfiguredLevel() {
75         Level JavaDoc result = Level.OFF;
76         try {
77             result = Level.parse(System.getProperty(CONFIGURED_LEVEL_PROPERTY_NAME, CONFIGURED_LEVEL_PROPERTY_DEFAULT));
78         } catch (Throwable JavaDoc thr) {
79             // Use the default OFF value but log the problem.
80
Logger JavaDoc logger = LogDomains.getLogger(LogDomains.DPL_LOGGER);
81             logger.log(Level.WARNING, thr.getLocalizedMessage(), thr);
82         }
83         return result;
84     }
85 }
86
Popular Tags