KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > ext > logging > LogAnalyzer


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
25 package com.sun.appserv.management.ext.logging;
26
27 import java.util.Collections JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.Set JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Date JavaDoc;
32
33 import java.util.logging.Level JavaDoc;
34
35
36 /**
37     Provides summary information about important logging events.
38     <big>PRELIMINARY--SUBJECT TO CHANGES/ADDITIONS</big>
39     
40     @since AS 9.0
41  */

42 public interface LogAnalyzer
43 {
44     /**
45         Key into any Map returned from {@link #getErrorInfo}.
46         value is of type Long.
47     */

48     public static final String JavaDoc TIMESTAMP_KEY = "TimeStamp";
49     
50     /**
51         Key into any Map returned from {@link #getErrorInfo}.
52         value is of type Long.
53     */

54     public static final String JavaDoc SEVERE_COUNT_KEY = "SevereCount";
55     
56     /**
57         Key into any Map returned from {@link #getErrorInfo}.
58         value is of type Long.
59     */

60     public static final String JavaDoc WARNING_COUNT_KEY = "WarningCount";
61     
62     /**
63         Key into any Map returned from {@link #getErrorDistribution}.
64         value is of type String.
65     */

66     public static final String JavaDoc MODULE_NAME_KEY = "ModuleName";
67     
68     
69     /**
70         Get a summary of the {@link Level#SEVERE} and {@link Level#WARNING} log
71         entries for the known history. Each entry in the resulting array is a
72         Map with the following keys:
73         <ul>
74         <li>{@link #TIMESTAMP_KEY} of type Long</li>
75         <li>{@link #SEVERE_COUNT_KEY} of type Integer</li>
76         <li>{@link #WARNING_COUNT_KEY} of type Integer</li>
77         </ul>
78         The entries are arranged from oldest to newest with the last entry being
79         the most recent.
80         <p>
81         The timestamp obtained from each Map may be used as the timestamp when
82         calling {@link #getErrorDistribution}. For example:<br>
83 <code>
84 final Map<String,Number>[] infos = logging.getErrorInfo();<br>
85 for( int i = 0; i < infos.length; ++i ) {<br>
86     final Map<String,Object> info = infos[ i ];<br>
87     final long timestamp = ((Long)info.get( TIMESTAMP_KEY )).longValue();<br>
88     <br>
89     Map<String,Number> counts = getErrorDistribution( timestamp );<br>
90 }
91 </code>
92         
93         @return Map<String,Number>
94      */

95     public Map JavaDoc<String JavaDoc,Number JavaDoc>[] getErrorInfo();
96     
97     
98     /**
99         Get the number of log entries for a particular timestamp of a particular {@link Level}
100         for all modules. SEVERE and WARNING are the only levels supported.
101         <p>
102         The resulting Map is keyed by the module ID, which may be any of the values
103         found in {@link LogModuleNames} or any valid Logger name.
104         The corresponding value
105         is the count for that module of the requested level.
106         <p>
107         
108         @param timestamp a timestamp as obtained using TIME_STAMP_KEY from one of the Maps
109         returned by {@link #getErrorInfo}. Note that it is a 'long' not a 'Long' and is required.
110         @param level
111         @return Map<String,Integer>
112      */

113     public Map JavaDoc<String JavaDoc,Integer JavaDoc> getErrorDistribution(long timestamp, String JavaDoc level);
114     
115     /**
116         @return all the logger names currently in use
117      */

118     public String JavaDoc[] getLoggerNames();
119     
120     /**
121         @return all the logger names currently in use under this logger.
122      */

123     public String JavaDoc[] getLoggerNamesUnder( String JavaDoc loggerName );
124     
125     /**
126         Set the number of intervals error statistics should be maintained.
127      
128         @param numIntervals number of intervals
129      */

130     public void setKeepErrorStatisticsForIntervals(final int numIntervals );
131     
132     /*
133         See {@link #setErrorStatisticsIntervals}.
134      */

135     public int getKeepErrorStatisticsForIntervals();
136
137     /**
138         Set the duration of an interval.
139     
140         @param minutes The duration of an interval in minutes.
141      */

142     public void setErrorStatisticsIntervalMinutes(final long minutes);
143     
144     /*
145         See {@link #setErrorStatisticsIntervalMinutes}.
146      */

147     public long getErrorStatisticsIntervalMinutes();
148 }
149
150
151
152
153
154
155
Popular Tags