LogMBeanpublic class LogMBean extends NotificationBroadcasterSupport implements DynamicMBeanLog MBean can
1. Fetch the Loggers available in the server
2. Fetch the log level of a given logger
3. Dynamically change the log levels of all the avalaible Loggers
4. Send SEVERE and WARNING Log messages as Alarms to all the interested
parties. |
Fields Summary |
---|
private static final int | MINUTES_TO_MILLISECONDS | private static final String | LOGS_DIR | private ObjectName | objectName | private LogRotatorSPI | accessLogRotator | private static final String | LOG_MBEAN_DESCRIPTION | private static final String | GET_LOGGER_NAMES | private static final String | GET_LOGGER_NAMES_DESCRIPTION | private static final String | GET_LOGGER_NAMES_UNDER | private static final String | GET_LOGGER_NAMES_UNDER_DESCRIPTION | private static final String | GET_LOG_LEVEL | private static final String | GET_LOG_LEVEL_DESCRIPTION | private static final String | SET_LOG_LEVEL | private static final String | SET_LOG_LEVEL_DESCRIPTION | private static final String | SET_LOG_LEVEL_FOR_MODULE | private static final String | SET_LOG_LEVEL_FOR_MODULE_DESCRIPTION | private static final String | GET_LOG_RECORD_USING_QUERY | private static final String | GET_LOG_RECORD_USING_QUERY_DESCRIPTION | private static final String | GET_ARCHIVED_LOG_FILES | private static final String | GET_ARCHIVED_LOG_FILES_DESCRIPTION | private static final String | GET_DIAGNOSTIC_CAUSES_FOR_MESSAGEID | private static final String | GET_DIAGNOSTIC_CAUSES_FOR_MESSAGEID_DESCRIPTION | private static final String | GET_DIAGNOSTIC_CHECKS_FOR_MESSAGEID | private static final String | GET_DIAGNOSTIC_CHECKS_FOR_MESSAGEID_DESCRIPTION | private static final String | GET_DIAGNOSTIC_URI_FOR_MESSAGEID | private static final String | GET_DIAGNOSTIC_URI_FOR_MESSAGEID_DESCRIPTION | private static final String | ROTATE_NOW | private static final String | ROTATE_NOW_DESCRIPTION | private static final String | GET_LOGFILES_DIRECTORY | private static final String | GET_ERROR_DISTRIBUTION | private static final String | GET_ERROR_DISTRIBUTION_DESCRIPTION | private static final String | GETLOGNAMES4LOGMODULE | private static final String | GETLOGNAMES4LOGMODULE_DESCRIPTION | private static final String | GET_LOGFILES_DIRECTORY_DESCRIPTION | private static final String | NOTIFICATION_SEVERE_ALARM | private static final String | NOTIFICATION_SEVERE_ALARM_DESCRIPTION | private static final String | NOTIFICATION_WARNING_ALARM | private static final String | NOTIFICATION_WARNING_ALARM_DESCRIPTION | private static final String | ATTR_LOGGER_NAMES | private static final String | ATTR_LOGGER_NAMES_DESCRIPTION | private static final String | ATTR_LOGFILES_DIRECTORY | private static final String | ATTR_LOGFILES_DIRECTORY_DESCRIPTION | private static final String | ATTR_ARCHIVED_LOG_FILES | private static final String | ATTR_ARCHIVED_LOG_FILES_DESCRIPTION | private static final String | ATTR_ERROR_INFORMATION | private static final String | ATTR_ERROR_INFORMATION_DESCRIPTION | private static final String | ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS | private static final String | ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS_DESCRIPTION | private static final String | ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS | private static final String | ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS_DESCRIPTION | private static final String | ATTR_ERROR_STATISTICS_INTERVAL_DURATION | private static final String | ATTR_ERROR_STATISTICS_INTERVAL_DURATION_DESCRIPTION | private static final MBeanOperationInfo[] | operationInfoArray | private static final MBeanAttributeInfo[] | attributeInfoArray | private static final MBeanInfo | _mBeanInfoInfo on this MBean | private static LogMBean | mbeanInstance |
Constructors Summary |
---|
private LogMBean()A private default constructor to ensure Singleton pattern for LogMBean.
|
Methods Summary |
---|
public void | changeLogFileName(java.lang.String fileName)This is an internal SPI to change the file name for FileandSyslogHandler
FileandSyslogHandler.getInstance().changeFileName( fileName );
| public boolean | findLogger(java.lang.String loggerName)check if logger already existes
Enumeration allLoggers = LogManager.getLogManager().getLoggerNames( );
while( allLoggers.hasMoreElements( ) ) {
String name = (String)allLoggers.nextElement();
if (loggerName.equals(name))
return true;
}
return false;
| public java.lang.String[] | getArchivedLogFiles()Gets all Archived log Files in the current Server instance.
String[] archivedLogFiles = new String[0];
try {
String instDir = System.getProperty(
SystemPropertyConstants.INSTANCE_ROOT_PROPERTY );
String[] names = { instDir, LOGS_DIR };
String logDir = StringUtils.makeFilePath( names, false );
File file = new File( logDir );
archivedLogFiles = file.list( new FilenameFilterImpl( ) );
// Get the current log file name and see if we have that on the list already.
// This is a corner case where user would not have given ".log" extension to
// log file and the FileNameFilter has filtered it.
// Also note that we are interested in getting just the filename, not the
// completepath
String currentFileName = new File(
ServerLogManager.getLogService( ).getFile( )).getName( );
boolean foundCurrentFile = false;
int i = 0;
for( i = 0; i < archivedLogFiles.length; i++ ) {
if( currentFileName.equals( archivedLogFiles[i] ) ) {
foundCurrentFile = true;
break;
}
}
if( !foundCurrentFile ) {
// If we don't have the currentLogFile in the list, then it must be
// because it doesn't use .log extension. Now, build a new list with
// the current log file name and the list returned from file.list( )
String[] newArchivedLogFiles = new String[ archivedLogFiles.length + 1 ];
newArchivedLogFiles[0] = currentFileName;
for( i = 1; i < (archivedLogFiles.length + 1); i++ ) {
newArchivedLogFiles[i] = archivedLogFiles[i - 1];
}
return newArchivedLogFiles;
}
} catch( Exception e ) {
// This will go into System.err Logger. As this failure is in
// the log module, we will stick with System.err here.
System.err.println(
"Exception in LogMBean.getArchivedLogFiles.." + e );
throw new RuntimeException(
"Exception in LogMBean.getArchivedLogFiles.." + e );
}
return archivedLogFiles;
| public java.lang.Object | getAttribute(java.lang.String attribute)Obtains the value of a specific monitored attribute. The LogMBean does
not have any attribute, this method always throws
AttributeNotFoundException when specified attribute is not null.
Object result = null;
if ( ATTR_LOGGER_NAMES.equals( attribute ) ) {
result = getLoggerNames();
}
else if ( ATTR_LOGFILES_DIRECTORY.equals( attribute ) ) {
result = getLogFilesDirectory();
}
else if ( ATTR_ARCHIVED_LOG_FILES.equals( attribute ) ) {
result = getArchivedLogFiles();
}
else if ( ATTR_ERROR_INFORMATION.equals( attribute ) ) {
result = getErrorInformation();
}
else if ( ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS.equals( attribute ) ) {
result = getKeepErrorStatisticsForIntervals();
}
else if ( ATTR_ERROR_STATISTICS_INTERVAL_DURATION.equals( attribute ) ) {
result = getErrorStatisticsIntervalMinutes();
}
else if ( ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS.equals( attribute ) ) {
result = getKeepErrorStatisticsForHours();
}
else {
if (attribute != null) {
throw new AttributeNotFoundException("Attribute " + attribute
+ " not found in LogMBean. There are no attributes.");
} else {
throw new IllegalArgumentException("Attribute Name is null");
}
}
return result;
| public javax.management.AttributeList | getAttributes(java.lang.String[] attributeNames)Get the values of several attributes of the monitoring MBean. LogMBean
does not have any attributes, so this method will always return an
empty attribute list.
final AttributeList attrs = new AttributeList();
for( final String name : attributeNames )
{
try
{
final Object value = getAttribute( name );
attrs.add( new Attribute( name, value ) );
}
catch( Exception e )
{
// ignore, per JMX spec
}
}
return attrs;
| public java.util.Map | getErrorDistribution(long timeStamp, java.util.logging.Level level)
return ErrorStatistics.singleton().
getErrorDistribution(timeStamp, level);
| public java.util.List | getErrorInformation()
return ErrorStatistics.singleton().getErrorInformation();
| public long | getErrorStatisticsIntervalMinutes()
return ErrorStatistics.singleton().getIntervalDuration() /
MINUTES_TO_MILLISECONDS;
| public static synchronized com.sun.enterprise.server.logging.LogMBean | getInstance()A Singleton factory method.
if( mbeanInstance == null ) {
mbeanInstance = new LogMBean();
}
return mbeanInstance;
| public int | getKeepErrorStatisticsForHours()
return ErrorStatistics.singleton().getNumOfIntervals();
| public int | getKeepErrorStatisticsForIntervals()
return ErrorStatistics.singleton().getNumOfIntervals();
| public java.lang.String | getLogFilesDirectory()This method returns the directory where log files are located.
try {
String fileName =
FileandSyslogHandler.getInstance( ).getAbsoluteLogFileName( );
return new File( fileName ).getParent( );
} catch( Exception e ) {
System.err.println( "Exception in LogMBean.getLogFilesDirectory()"
+ e );
}
return null;
| public java.lang.String | getLogLevel(java.lang.String loggerName)Gets the current Log Level of the given Logger. The 8 Possible values
are
1.SEVERE 2.WARNING 3.INFO 4.CONFIG 5.FINE 6.FINER 7.FINEST 8. Null
String logLevelInString = null;
Logger logger = Logger.getLogger( loggerName );
if( logger == null ) {
throw new RuntimeException( " Logger " + loggerName +
" does not exist" );
}
Level level = logger.getLevel( );
boolean foundParentLevel = false;
if( level == null ) {
while( !foundParentLevel ) {
logger = logger.getParent();
if ( logger == null ){
break;
}
level = logger.getLevel( );
if( level != null ) {
foundParentLevel = true;
}
}
}
if( level != null ) {
logLevelInString = level.toString();
}
return logLevelInString;
| public javax.management.AttributeList | getLogRecordsUsingQuery(java.lang.String logFilename, java.lang.Long fromRecord, java.lang.Boolean next, java.lang.Boolean forward, java.lang.Integer requestedCount, java.util.Date fromDate, java.util.Date toDate, java.lang.String logLevel, java.lang.Boolean onlyLevel, java.util.List listOfModules, java.util.Properties nameValueMap)The public method that Log Viewer Front End will be calling on.
The query will be run on records starting from the fromRecord.
If any of the elements for the query is null, then that element will
not be used for the query. If the user is interested in viewing only
records whose Log Level is SEVERE and WARNING, then the query would
look like:
fromDate = null, toDate = null, logLevel = WARNING, onlyLevel = false,
listOfModules = null, nameValueMap = null.
return LogFilter.getLogRecordsUsingQuery(logFilename, fromRecord, next,
forward, requestedCount, fromDate, toDate, logLevel, onlyLevel,
listOfModules, nameValueMap);
| public java.util.List | getLoggerNames()Gets all the Loggers currently running in the System. The returned
list is not sorted.
LinkedList loggerNamesList = new LinkedList( );
Enumeration allLoggers = LogManager.getLogManager().getLoggerNames( );
while( allLoggers.hasMoreElements( ) ) {
loggerNamesList.add(allLoggers.nextElement( ));
}
return loggerNamesList;
| public java.util.List | getLoggerNamesUnder(java.lang.String loggerName)Gets all the Loggers under a given logger. The returned list is not
sorted.
LinkedList filteredList = new LinkedList( );
Iterator allLoggersIterator = getLoggerNames( ).iterator( );
while( allLoggersIterator.hasNext( ) ) {
String t = (String) allLoggersIterator.next( );
if( t.startsWith( loggerName ) ) {
filteredList.add( t );
}
}
return filteredList;
| public java.util.List | getLognames4LogModule(java.lang.String logModuleName)
String[] names = ModuleToLoggerNameMapper.getLoggerNames(logModuleName);
return Arrays.asList(names);
| public javax.management.MBeanInfo | getMBeanInfo()Provides the exposed attributes and actions of the monitoring MBean using
an MBeanInfo object.
return _mBeanInfo;
| public static javax.management.MBeanInfo | initializeMBeanInfo()
MBeanInfo mBeanInfo = null;
try {
if ( attributeInfoArray.length != 7 ) {
throw new RuntimeException(
"attributeInfoArray array is the wrong length" );
}
attributeInfoArray[0] = new MBeanAttributeInfo(
ATTR_LOGGER_NAMES, "java.util.List",
ATTR_LOGGER_NAMES_DESCRIPTION, true, false, false);
attributeInfoArray[1] = new MBeanAttributeInfo(
ATTR_LOGFILES_DIRECTORY, "String",
ATTR_LOGFILES_DIRECTORY_DESCRIPTION, true, false, false);
attributeInfoArray[2] = new MBeanAttributeInfo(
ATTR_ARCHIVED_LOG_FILES, "[Ljava.lang.String;",
ATTR_ARCHIVED_LOG_FILES_DESCRIPTION, true, false, false);
attributeInfoArray[3] = new MBeanAttributeInfo(
ATTR_ERROR_INFORMATION, List.class.getName(),
ATTR_ERROR_INFORMATION_DESCRIPTION, true, false, false);
attributeInfoArray[4] = new MBeanAttributeInfo(
ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS, int.class.getName(),
ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS_DESCRIPTION,
true, true, false);
attributeInfoArray[5] = new MBeanAttributeInfo(
ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS, int.class.getName(),
ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS_DESCRIPTION,
true, true, false);
attributeInfoArray[6] = new MBeanAttributeInfo(
ATTR_ERROR_STATISTICS_INTERVAL_DURATION, long.class.getName(),
ATTR_ERROR_STATISTICS_INTERVAL_DURATION_DESCRIPTION,
true, true, false);
MBeanParameterInfo[] loggerNameParam =
{new MBeanParameterInfo("LoggerName", "String", "Logger Name")};
operationInfoArray[0] = new MBeanOperationInfo(
GET_LOGGER_NAMES_UNDER, GET_LOGGER_NAMES_UNDER_DESCRIPTION,
loggerNameParam, "java.util.List", MBeanOperationInfo.ACTION);
operationInfoArray[1] = new MBeanOperationInfo(GET_LOG_LEVEL,
GET_LOG_LEVEL_DESCRIPTION, loggerNameParam, "String",
MBeanOperationInfo.ACTION);
MBeanParameterInfo[] loggerNameAndLevelParam =
{new MBeanParameterInfo("LoggerName", "String", "Logger Name"),
new MBeanParameterInfo("LogLevel", "String", "Logger Level") };
operationInfoArray[2] = new MBeanOperationInfo(SET_LOG_LEVEL,
SET_LOG_LEVEL_DESCRIPTION, loggerNameAndLevelParam, "void",
MBeanOperationInfo.ACTION);
operationInfoArray[3] = new MBeanOperationInfo(
SET_LOG_LEVEL_FOR_MODULE, SET_LOG_LEVEL_FOR_MODULE_DESCRIPTION,
loggerNameAndLevelParam, "void", MBeanOperationInfo.ACTION);
MBeanParameterInfo[] logviewerQueryParams =
{new MBeanParameterInfo("FileName", "String",
" If Filename is specified then it will be used to " +
" run the query. If the user specifies null for this " +
" argument then the current server.log file will be " +
" used to run the query. This argument is specifed to " +
" typically run query on Archived Log File "),
new MBeanParameterInfo("FromRecord", "Long",
"The location within the LogFile"),
new MBeanParameterInfo("next", "Boolean",
"True to get the next set of results and False to get " +
" the previous results "),
new MBeanParameterInfo("forward", "Boolean",
"True to search forward through the log file " ),
new MBeanParameterInfo("requestedCount", "Integer",
"Number of desired records" ),
new MBeanParameterInfo("fromDate", "java.util.Date",
" The lower bound date " ),
new MBeanParameterInfo("toDate", "java.util.Date",
" The upper bound date " ),
new MBeanParameterInfo("logLevel", "String",
" The minimum log level to display " ),
new MBeanParameterInfo("onlyLevel", "Boolean",
" True to only display messsage for \"logLevel\""),
new MBeanParameterInfo("listOfModules", "java.util.List",
" List Of Modules and Logger Names To Match" ),
new MBeanParameterInfo("nameValueMap", "java.util.Properties",
" List Of Name Value Pairs to match " )
};
operationInfoArray[4] = new MBeanOperationInfo(
GET_LOG_RECORD_USING_QUERY,
GET_LOG_RECORD_USING_QUERY_DESCRIPTION,
logviewerQueryParams, "javax.management.AttributeList",
MBeanOperationInfo.ACTION);
MBeanParameterInfo[] diagnosticsParameter =
{new MBeanParameterInfo("messageId", "String", "Error Code") };
operationInfoArray[5] = new MBeanOperationInfo(
GET_DIAGNOSTIC_CAUSES_FOR_MESSAGEID,
GET_DIAGNOSTIC_CAUSES_FOR_MESSAGEID_DESCRIPTION,
diagnosticsParameter, "java.util.ArrayList",
MBeanOperationInfo.ACTION);
operationInfoArray[6] = new MBeanOperationInfo(
GET_DIAGNOSTIC_CHECKS_FOR_MESSAGEID,
GET_DIAGNOSTIC_CHECKS_FOR_MESSAGEID_DESCRIPTION,
diagnosticsParameter, "java.util.ArrayList",
MBeanOperationInfo.ACTION);
operationInfoArray[7] = new MBeanOperationInfo(
GET_DIAGNOSTIC_URI_FOR_MESSAGEID,
GET_DIAGNOSTIC_URI_FOR_MESSAGEID_DESCRIPTION,
diagnosticsParameter, "String", MBeanOperationInfo.ACTION);
operationInfoArray[8] = new MBeanOperationInfo(
ROTATE_NOW, ROTATE_NOW_DESCRIPTION,
null, "void", MBeanOperationInfo.ACTION);
final MBeanParameterInfo[] getErrorDistributionParams =
{
new MBeanParameterInfo("name", "long","time stamp"),
new MBeanParameterInfo("name", Level.class.getName(), "log level")
};
operationInfoArray[9] = new MBeanOperationInfo(
GET_ERROR_DISTRIBUTION, GET_ERROR_DISTRIBUTION_DESCRIPTION,
getErrorDistributionParams, List.class.getName(), MBeanOperationInfo.INFO);
MBeanParameterInfo[] moduleNameParam =
{new MBeanParameterInfo("ModuleName", "String", "Module Name")};
operationInfoArray[10] = new MBeanOperationInfo(
GETLOGNAMES4LOGMODULE,
GETLOGNAMES4LOGMODULE_DESCRIPTION,
moduleNameParam, "java.util.List", MBeanOperationInfo.ACTION);
String[] alarmTypes = {NOTIFICATION_SEVERE_ALARM,
NOTIFICATION_WARNING_ALARM};
MBeanNotificationInfo[] notificationInfo =
{new MBeanNotificationInfo( alarmTypes, "Alarms",
"Severe and Warning Log Messages will be notified ") };
mBeanInfo = new MBeanInfo("LogMBean", LOG_MBEAN_DESCRIPTION,
attributeInfoArray, null, operationInfoArray,
notificationInfo);
// Now Try to register the LogMBean
//new RegisterLogMBean( this ).start( );
} catch( Exception e ) {
new ErrorManager().error(
"Error in LogMBean Initialization", e,
ErrorManager.GENERIC_FAILURE );
}
return mBeanInfo;
| private void | internalSetLogLevel(java.lang.String loggerName, java.util.logging.Level level)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Logger.getLogger( loggerName ).setLevel(level);
return null;
}});
| public java.lang.Object | invoke(java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
if( operationName == null || operationName.equals("")) {
throw new RuntimeOperationsException(
new IllegalArgumentException( "MBean.invoke operation name is "+
" null " ) );
}
AttributeList resultList = new AttributeList();
if( operationName.equals( GET_LOGGER_NAMES ) ) {
return getLoggerNames( );
} else if( operationName.equals( GET_LOGGER_NAMES_UNDER ) ) {
String loggerName = (String) params[0];
return getLoggerNamesUnder( loggerName );
} else if( operationName.equals( GETLOGNAMES4LOGMODULE ) ) {
String module = (String) params[0];
return getLognames4LogModule(module);
} else if( operationName.equals( GET_LOG_LEVEL ) ) {
String loggerName = (String) params[0];
return getLogLevel( loggerName );
} else if( operationName.equals( SET_LOG_LEVEL ) ) {
String loggerName = (String) params[0];
String loglevel = (String) params[1];
setLogLevel( loggerName, loglevel );
} else if( operationName.equals( SET_LOG_LEVEL_FOR_MODULE ) ) {
String module = (String) params[0];
String loglevel = (String) params[1];
setLogLevel( module, loglevel );
} else if( operationName.equals( GET_LOG_RECORD_USING_QUERY) ) {
String fileName = (String) params[0];
Long fromRecord = (Long) params[1];
Boolean next = (Boolean) params[2];
Boolean forward = (Boolean) params[3];
Integer requestedCount = (Integer) params[4];
Date fromDate = (Date) params[5];
Date toDate = (Date) params[6];
String logLevel = (String) params[7];
Boolean onlyLevel = (Boolean) params[8];
List listOfModules = (java.util.List) params[9];
java.util.Properties nvMap = (java.util.Properties) params[10];
return getLogRecordsUsingQuery( fileName, fromRecord, next, forward,
requestedCount, fromDate, toDate, logLevel, onlyLevel,
listOfModules, nvMap );
} else if( operationName.equals( GET_ARCHIVED_LOG_FILES ) ) {
return getArchivedLogFiles( );
} else if( operationName.equals( GET_DIAGNOSTIC_CAUSES_FOR_MESSAGEID )){
String messageId = (String) params[0];
return
MessageIdCatalog.getInstance().getDiagnosticCausesForMessageId(
messageId );
} else if( operationName.equals( GET_DIAGNOSTIC_CHECKS_FOR_MESSAGEID )){
String messageId = (String) params[0];
return
MessageIdCatalog.getInstance().getDiagnosticChecksForMessageId(
messageId );
} else if( operationName.equals( GET_DIAGNOSTIC_URI_FOR_MESSAGEID )){
String messageId = (String) params[0];
return
MessageIdCatalog.getInstance().getDiagnosticURIForMessageId(
messageId );
} else if( operationName.equals( ROTATE_NOW ) ) {
this.rotateNow( );
} else if( operationName.equals( GET_LOGFILES_DIRECTORY ) ) {
return this.getLogFilesDirectory( );
} else if( operationName.equals( GET_ERROR_DISTRIBUTION ) ) {
return this.getErrorDistribution( (Long)params[0], (Level)params[1] );
} else {
throw new IllegalArgumentException(
"Requested operation " + operationName + " does not exist..." );
}
return resultList;
| private void | raiseAlarm(java.lang.String type, java.util.logging.LogRecord record)
LogAlarm logAlarm = new LogAlarm( type, this, record );
sendNotification( logAlarm );
| void | raiseSevereAlarm(java.util.logging.LogRecord record)This method raises a SEVERE type Alarm.
raiseAlarm( NOTIFICATION_SEVERE_ALARM, record );
| void | raiseWarningAlarm(java.util.logging.LogRecord record)This method raises a WARNING type Alarm.
raiseAlarm( NOTIFICATION_WARNING_ALARM, record );
| public void | rotateAccessLog()This method rotates the accessLog
if( accessLogRotator != null ) {
accessLogRotator.rotate( );
}
| public void | rotateNow()This method rotates the server.log and access log file at this instant.
FileandSyslogHandler.getInstance( ).requestRotation( );
// Rotate Access Log also
this.rotateAccessLog( );
| public void | setAccessLogRotator(LogRotatorSPI logRotator)Setter provided to set the AccessLog Rotator.
accessLogRotator = logRotator;
| public void | setAttribute(javax.management.Attribute attribute)Set the value of specified attribute. This method throws exception as
LogMBean does not have any attributes.
final String name = attribute.getName();
final Object value = attribute.getValue();
if ( ATTR_KEEP_ERROR_STATISTICS_FOR_INTERVALS.equals( name ) ) {
setKeepErrorStatisticsForIntervals( (Integer)value );
}
else if ( ATTR_ERROR_STATISTICS_INTERVAL_DURATION.equals( name ) ) {
setErrorStatisticsIntervalMinutes( (Long)value );
}
else if ( ATTR_KEEP_ERROR_STATISTICS_FOR_HOURS.equals( name ) ) {
setKeepErrorStatisticsForHours( (Integer)value );
}
else {
throw new AttributeNotFoundException( name );
}
| public javax.management.AttributeList | setAttributes(javax.management.AttributeList list)Set the values of several attributes. As LogMBean does not have any
attributes, the method will always return empty attribute list.
final AttributeList result = new AttributeList();
for( final Object o : list ) {
final Attribute attr = (Attribute)o;
try {
setAttribute( attr );
result.add( attr );
}
catch( Throwable t ) {
// OK, per semantics of setAttributes();
}
}
return result;
| public void | setErrorStatisticsIntervalMinutes(long minutes)Set the duration of an interval, in minutes.
ErrorStatistics.singleton().setIntervalDuration(
minutes*MINUTES_TO_MILLISECONDS);
| public void | setKeepErrorStatisticsForHours(int hours)Set the number of hours error statistics should be maintained.
ErrorStatistics.singleton().setNumOfIntervals(hours);
| public void | setKeepErrorStatisticsForIntervals(int numberOfIntervals)Set the number of intervals error statistics should be maintained.
ErrorStatistics.singleton().setNumOfIntervals(numberOfIntervals);
| public void | setLogLevel(java.lang.String loggerName, java.lang.String level)Sets the log level of the given logger to the request level. An
Exception will be raised if the level is not one of the following 8
values.
1.SEVERE 2.WARNING 3.INFO 4.CONFIG 5.FINE 6.FINER 7.FINEST 8.OFF
JDK's java.util.logging.Level.parse will throw IllegalArgument exception
if a wrong value is used for the Level.
Apparently there seems to be a problem in propogating LogLevel from
parent to child loggers in JDK. So, using this internal method to
set the level for all the individual loggers...
internalSetLogLevel(loggerName,Level.parse(level) );
/* Level logLevel = Level.parse( level );
// NOTE: Don't have to check for listIterator being null, because
// even if a wrong logger name is used, a null list will be returned.
Iterator listIterator = getLoggerNamesUnder( loggerName ).iterator();
while ( listIterator.hasNext( ) ) {
internalSetLogLevel( (String) listIterator.next(), logLevel );
}
*/
| public void | setLogLevelForModule(java.lang.String module, java.lang.String level)Sets the log level for the given module to the request level. An
Exception will be raised if the level is not one of the following 8
values.
1.SEVERE 2.WARNING 3.INFO 4.CONFIG 5.FINE 6.FINER 7.FINEST 8.OFF
String[] loggerNames = ModuleToLoggerNameMapper.getLoggerNames( module );
for (int i=0;loggerNames!=null&&i<loggerNames.length;i++) {
setLogLevel(loggerNames[i], level );
}
|
|