本文整理汇总了Java中java.util.logging.Logger.severe方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.severe方法的具体用法?Java Logger.severe怎么用?Java Logger.severe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.logging.Logger
的用法示例。
在下文中一共展示了Logger.severe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loglevel
import java.util.logging.Logger; //导入方法依赖的package包/类
public void loglevel(Level l, Logger logger, String message) {
LogTest test = LogTest.valueOf("LEV_"+l.getName());
switch(test) {
case LEV_SEVERE:
logger.severe(message);
break;
case LEV_WARNING:
logger.warning(message);
break;
case LEV_INFO:
logger.info(message);
break;
case LEV_CONFIG:
logger.config(message);
break;
case LEV_FINE:
logger.fine(message);
break;
case LEV_FINER:
logger.finer(message);
break;
case LEV_FINEST:
logger.finest(message);
break;
}
}
示例2: notifySafe
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Calls notifier.notify() on each of the stored listeners, allowing you to execute stored
* command.
* <p><p>
* Every notification is run inside try/catch block, exceptions are reported into the log
* (if not null) and method returns false if some exception is thrown.
*
* @param notifier
* @param exceptionLog where to log exceptions, may be null
* @return true, if no exception happened
*/
public boolean notifySafe(ListenerNotifier<Listener> notifier, Logger exceptionLog) {
boolean noException = true;
synchronized(listeners) {
boolean listenersIterationOriginal = listenersIteration;
listenersIteration = true;
try {
Iterator<ListenerStore<Listener>> iterator = listeners.iterator();
while(iterator.hasNext()) {
ListenerStore<Listener> store = iterator.next();
Listener storedListener = store.getListener();
if (storedListener == null) {
if (!listenersIterationOriginal) {
if ((store instanceof WeakListenerStore) && log != null && log.isLoggable(Level.FINE)) {
log.fine((name == null ? "" : name + ": ") + "Weakly referenced listener was GC()ed.");
}
iterator.remove();
}
continue;
}
try {
notifier.notify(storedListener);
} catch (Exception e) {
noException = false;
if (exceptionLog != null) {
if (exceptionLog.isLoggable(Level.SEVERE)) exceptionLog.severe(ExceptionToString.process("Exception during event processing (" + notifier.getEvent() + ").", e));
}
}
}
} finally {
listenersIteration = listenersIterationOriginal;
}
}
return noException;
}
示例3: logException
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Logs the exception to the log + sets isLogged() to true.
*/
public synchronized void logException(Logger log) {
try {
if (log == null) return;
if (log.isLoggable(Level.SEVERE)) log.severe(ExceptionToString.process(getMessage(), this));
this.hasBeenLogged = true;
} catch (Exception e) {
System.err.println("PogamutException (and can't log to log '"+log.getName()+"' because \""+e.getMessage()+"\"), exception: " + toString());
this.printStackTrace(System.err);
}
}
示例4: isSubset
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Checks, whether THIS {@link IniFile} is the subset of 'other'.
* @param other
* @param thisName
* @param otherName
* @param log
* @return
*/
public boolean isSubset(IniFile other, String thisName, String otherName, Logger log) {
for (Section thisSection : this.getSections()) {
log.info("Checking section [" + thisSection.getName() + "]");
Section otherSection = other.getSection(thisSection.getName());
if (otherSection == null) {
if (log != null) log.severe(thisName + " INI contains Section[" + thisSection.getName() + "] that is not present within Read INI (source)!");
return false;
}
for (String key : thisSection.getKeys()) {
List<String> thisValues = thisSection.getAll(key);
List<String> otherValues = new ArrayList<String>(otherSection.getAll(key));
if (log != null) log.info("Checking key: " + key + " (" + thisValues.size() + " values)");
if (thisValues.size() != otherValues.size()) {
if (log != null) log.severe(thisName + " INI, Section[" + thisSection.getName() + "], Key[" + key + "] contains #values == " + thisValues.size() + " != " + otherValues.size() + " == #values within " + otherName + " INI (source)!");
}
for (String testValue : thisValues) {
boolean present = false;
for (int i = 0; i < otherValues.size(); ++i) {
String otherValue = otherValues.get(i);
if (SafeEquals.equals(testValue, otherValue)) {
present = true;
otherValues.remove(i);
break;
}
}
if (present) continue;
// ERROR!
if (log != null) log.severe(thisName + " INI, Section[" + thisSection.getName() + "], Key[" + key + "] contains Value[" + testValue + "] that is not present within " + otherName + " section/key!");
return false;
}
}
}
return true;
}
示例5: check
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Checks the validity of the specified event.
* @param logger
* @param event
*/
public boolean check(Logger logger, Event event) {
boolean result = true;
for (String role : event.getRoles())
if (!roles.containsKey(role)) {
logger.severe(event.getId() + " (" + type + ") does not allow the role " + role);
result = false;
}
for (RoleSchema roleSchema : roles.values())
result = roleSchema.check(logger, event) && result;
return result;
}
示例6: RedisModule
import java.util.logging.Logger; //导入方法依赖的package包/类
public RedisModule(File configFile, Logger logger) {
this.logger = logger;
this.configFile = configFile;
this.redisConnection = new RedisConnection();
try {
this.config = configFile.getName().endsWith(".json") ? Config.fromJSON(configFile) : Config.fromYAML(configFile);
}
catch(IOException e) {
logger.severe("Error while loading Redis config! " + e);
super.finished(false);
}
}
示例7: init
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void init(ProcessingContext<T> ctx) throws ModuleException {
Class<?> klass = searchAlvisNLPModuleAnnotation();
if (klass == null)
throw new RuntimeException("class does not extend a module class");
AlvisNLPModule annot = klass.getAnnotation(AlvisNLPModule.class);
if (annot.beta())
getLogger(ctx).warning("this module is EXPERIMENTAL");
Class<?>[] better = annot.obsoleteUseInstead();
if (better.length == 0)
return;
Logger logger = getLogger(ctx);
logger.severe("this module class is DEPRECATED, use instead: " + Strings.joinStrings(Arrays.asList(better), ", "));
logger.severe("support for this module class may be DSCONTINUED WITHOUT NOTICE");
}
示例8: error
import java.util.logging.Logger; //导入方法依赖的package包/类
private void error(Logger logger, Exception e, String msg) {
logger.severe(msg);
if (logger.isLoggable(Level.FINEST)) {
for (Throwable t = e; t != null; t = t.getCause()) {
logger.finest(t.getClass().getCanonicalName());
for (StackTraceElement ste : t.getStackTrace())
logger.finest(" " + ste);
}
}
else
logger.info("use -verbose option to get debug info");
exitCode = 1;
}
示例9: check
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Checks the validity of the specified event for this role.
* @param logger
* @param event
*/
public boolean check(Logger logger, Event event) {
if (event.hasArg(name))
return check(logger, event.getArg(name));
if (mandatory) {
logger.severe(event.getId() + " has no arg with role " + name);
return false;
}
return true;
}
示例10: process
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
try {
Logger logger = getLogger(ctx);
EvaluationContext evalCtx = new EvaluationContext(logger);
List<List<Layer>> sentenceRuns = getSentences(logger, evalCtx, corpus);
for (int run = 0; run < sentenceRuns.size(); ++run) {
logger.info(String.format("run %d/%d", run+1, sentenceRuns.size()));
List<Layer> sentences = sentenceRuns.get(run);
CCGParserExternal parserExt = new CCGParserExternal(ctx, run, getMaxLength(sentences));
TargetStream target = new FileTargetStream(internalEncoding, parserExt.input);
try (PrintStream out = target.getPrintStream()) {
printSentences(ctx, out, sentences, true);
}
try {
callExternal(ctx, "run-ccg", parserExt, internalEncoding, "ccg.sh");
}
catch (ExternalFailureException e) {
logger.severe(e.getMessage());
logger.severe("we know sometimes CCG accidentally the sentences");
logger.severe("let's try to proceed anyway. No guarantee...");
logger.severe("btw, input that caused the crash: " + parserExt.input.getAbsolutePath());
}
try (BufferedReader r = getBufferedReader(ctx, parserExt)) {
readSentences(ctx, r, sentences);
}
}
}
catch (UnsupportedEncodingException uee) {
rethrow(uee);
}
catch (FileNotFoundException fnfe) {
rethrow(fnfe);
}
catch (IOException ioe) {
rethrow(ioe);
}
}
示例11: check
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public boolean check(Logger logger) {
try {
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
return true;
}
catch (IOException ioe) {
logger.severe(ioe.getMessage());
return false;
}
}
示例12: main
import java.util.logging.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
String definition = "NetBeansPublicPackages.xml";
if (args.length > 0) {
definition = args[0];
if (definition == null) definition = "NetBeansPublicPackages.xml";
}
SimpleLogging.initLogging();
Logger log = Logger.getAnonymousLogger();
log.info("---[[ PUBLIC PACKAGES ]]---");
log.info("Loading definition from xml file: " + definition + " --> " + new File(definition).getAbsoluteFile());
File file = new File(definition);
if (!file.exists() || !file.isFile()) {
log.severe("FAILED! Definition file not found at: " + file.getAbsolutePath());
log.severe("Usage: java -jar NetBeansPublicPackages.jar [path-to-definition-xml-file]");
example(log);
log.info("---[[ END ]]---");
System.exit(1);
return;
}
NetBeansPublicPackages publicPackages;
try {
publicPackages = new NetBeansPublicPackages(file);
} catch (Exception e) {
e.printStackTrace();
log.severe("Usage: java -jar RewriteFiles.jar [path-to-definition-xml-file]");
example(log);
log.info("---[[ END ]]---");
return;
}
publicPackages.setLog(log);
log.info("Definition file loaded.");
boolean result = publicPackages.rewrite();
if (result) {
log.info("System.exit(0)");
} else {
log.warning("Failure! System.exit(1)!");
System.exit(1);
}
log.info("---[[ END ]]---");
if (result) {
System.exit(0);
} else {
System.exit(1);
}
}
示例13: test4
import java.util.logging.Logger; //导入方法依赖的package包/类
public void test4(Logger logger) {
System.out.println("test4: " + loggerName(logger));
AtomicInteger count = new AtomicInteger();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
logger.setLevel(Level.ALL);
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
logger.severe(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
LogEvent event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.warning(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.info(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.config(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.fine(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.finer(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
logger.finest(() -> "message " + count.incrementAndGet());
assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
event = TestHandler.PUBLISHED.remove();
assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
checkEvent(event, this.getClass().getName(), "test4", "message " + count.get());
}
示例14: checkReadable
import java.util.logging.Logger; //导入方法依赖的package包/类
protected static boolean checkReadable(Logger logger, File f) {
if (f.canRead())
return true;
logger.severe(f.getAbsolutePath() + " cannot be read");
return false;
}
示例15: checkWritable
import java.util.logging.Logger; //导入方法依赖的package包/类
protected static boolean checkWritable(Logger logger, File f) {
if (f.canWrite())
return true;
logger.severe(f.getAbsolutePath() + " cannot be written");
return false;
}