use of org.apache.geode.internal.logging.log4j.LogLevel in project geode by apache.
the class ChangeLogLevelFunction method execute.
@Override
public void execute(FunctionContext context) {
Cache cache = CacheFactory.getAnyInstance();
Map<String, String> result = new HashMap<String, String>();
try {
LogWriterLogger logwriterLogger = (LogWriterLogger) cache.getLogger();
Object[] args = (Object[]) context.getArguments();
final String logLevel = (String) args[0];
Level log4jLevel = LogLevel.getLevel(logLevel);
logwriterLogger.setLevel(log4jLevel);
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + LOG_LEVEL, logLevel);
// LOG:CONFIG:
logger.info(LogMarker.CONFIG, "GFSH Changed log level to {}", log4jLevel);
result.put(cache.getDistributedSystem().getDistributedMember().getId(), "New log level is " + log4jLevel);
context.getResultSender().lastResult(result);
} catch (Exception ex) {
// LOG:CONFIG:
logger.info(LogMarker.CONFIG, "GFSH Changing log level exception {}", ex.getMessage(), ex);
result.put(cache.getDistributedSystem().getDistributedMember().getId(), "ChangeLogLevelFunction exception " + ex.getMessage());
context.getResultSender().lastResult(result);
}
}
Aggregations