本文整理汇总了Java中java.util.logging.Logger.setUseParentHandlers方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.setUseParentHandlers方法的具体用法?Java Logger.setUseParentHandlers怎么用?Java Logger.setUseParentHandlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.logging.Logger
的用法示例。
在下文中一共展示了Logger.setUseParentHandlers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preferenceChange
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
if (corePref.equals(evt.getNode()) && USAGE_STATISTICS_ENABLED.equals(evt.getKey())) {
boolean newVal = Boolean.parseBoolean(evt.getNewValue());
if (newVal != logMetricsEnabled) {
corePref.putBoolean(USAGE_STATISTICS_SET_BY_IDE, true);
logMetricsEnabled = newVal;
Logger log = Logger.getLogger(METRICS_LOGGER_NAME);
if (logMetricsEnabled) {
log.setUseParentHandlers(true);
log.setLevel(Level.FINEST);
log.addHandler(metrics);
MetricsHandler.setFlushOnRecord(false);
} else {
MetricsHandler.flushImmediatelly();
closeLogStreamMetrics();
log.removeHandler(metrics);
}
}
}
}
示例2: createMetricUpdateTracer
import java.util.logging.Logger; //导入方法依赖的package包/类
private static Logger createMetricUpdateTracer() {
Logger logger = Logger.getLogger(TracingMetricRegistry.class.getName() + ".metricUpdates");
ConsoleHandler handler = new ConsoleHandler();
handler.setFormatter(new Formatter() {
@Override
public String format(LogRecord record) {
return ">>" + record.getMessage() + "\n";
}
});
logger.addHandler(handler);
logger.setUseParentHandlers(false);
handler.setLevel(Level.ALL);
//logger.setLevel(Level.ALL);
return logger;
}
示例3: setUp
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
branding = NbBundle.getBranding();
locale = Locale.getDefault();
clearWorkDir();
install = new File(getWorkDir(), "install");
platform = new File(install, "platform");
ide = createIdeCluster(install);
userdir = new File(getWorkDir(), "tmp");
System.setProperty("netbeans.home", platform.getPath());
System.setProperty("netbeans.dirs", ide.getPath());
System.setProperty("netbeans.user", userdir.getPath());
createModule("org.openide.awt", platform, 50000L);
createModule("org.openide.nodes", platform, 60000L);
createModule("org.netbeans.api.languages", ide, 90000L);
createModule("org.netbeans.modules.logmanagement", userdir, 10000L);
reset();
Thread.sleep(100);
Logger l = Logger.getLogger("org");
l.setLevel(Level.OFF);
l.setUseParentHandlers(false);
}
示例4: setUp
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
branding = NbBundle.getBranding();
locale = Locale.getDefault();
clearWorkDir();
install = new File(getWorkDir(), "install");
platform = new File(install, "platform");
ide = new File(install, "ide");
userdir = new File(getWorkDir(), "tmp");
System.setProperty("netbeans.home", platform.getPath());
System.setProperty("netbeans.dirs", ide.getPath());
System.setProperty("netbeans.user", userdir.getPath());
createModule("org.openide.awt", platform, 50000L);
createModule("org.openide.nodes", platform, 60000L);
createModule("org.netbeans.api.languages", ide, 90000L);
createModule("org.netbeans.modules.logmanagement", userdir, 10000L);
Thread.sleep(100);
createPopulateZip();
Logger l = Logger.getLogger("org");
l.setLevel(Level.OFF);
l.setUseParentHandlers(false);
}
示例5: setUp
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
clearWorkDir();
install = new File(getWorkDir(), "install");
platform = new File(install, "platform");
nonexist = new File(install, "nonexist7");
ide = new File(install, "ide");
userdir = new File(getWorkDir(), "tmp");
System.setProperty("netbeans.home", platform.getPath());
System.setProperty("netbeans.dirs", ide.getPath() + File.pathSeparator + nonexist.getPath());
PlacesTestUtils.setUserDirectory(userdir);
StampsTest.createModule("org.openide.awt", platform, 50000L);
StampsTest.createModule("org.openide.nodes", platform, 60000L);
StampsTest.createModule("org.netbeans.api.languages", ide, 50000L);
StampsTest.createModule("org.netbeans.modules.logmanagement", userdir, 10000L);
Stamps.main("reset");
Thread.sleep(100);
Logger l = Logger.getLogger("org");
l.setLevel(Level.OFF);
l.setUseParentHandlers(false);
}
示例6: getLogger
import java.util.logging.Logger; //导入方法依赖的package包/类
public Logger getLogger() throws IOException {
Logger logger = Logger.getLogger("qsync");
logger.setUseParentHandlers(false);
Handler handler = new FlushedStreamHandler(System.err, LogFormatter.INSTANCE);
logger.addHandler(handler);
if (logFile != null) {
Handler fileHandler = new FileHandler(logFile);
logger.addHandler(fileHandler);
}
return logger;
}
示例7: setUp
import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
branding = NbBundle.getBranding();
locale = Locale.getDefault();
clearWorkDir();
install = new File(getWorkDir(), "install");
platform = new File(install, "platform");
ide = new File(install, "ide");
userdir = new File(getWorkDir(), "tmp");
cache = new File(install, "cache");
System.setProperty("netbeans.home", platform.getPath());
System.setProperty("netbeans.dirs", ide.getPath());
System.setProperty("netbeans.user", userdir.getPath());
createModule("org.openide.awt", platform, 50000L);
createModule("org.openide.nodes", platform, 60000L);
createModule("org.netbeans.api.languages", ide, 90000L);
createModule("org.netbeans.modules.logmanagement", userdir, 10000L);
Thread.sleep(100);
createPopulateZip();
Logger l = Logger.getLogger("org");
l.setLevel(Level.OFF);
l.setUseParentHandlers(false);
}
示例8: restored
import java.util.logging.Logger; //导入方法依赖的package包/类
public @Override void restored() {
if (!ENABLED) {
return ;
}
Logger log = Logger.getLogger("TIMER"); // NOI18N
log.setUseParentHandlers(false);
log.setLevel(Level.FINE);
log.addHandler(timers);
EditorRegistry.addPropertyChangeListener(docTracker);
}
示例9: ScanMonitor
import java.util.logging.Logger; //导入方法依赖的package包/类
private ScanMonitor() {
Logger logger = Logger.getLogger("org.netbeans.modules.java.source.usages.RepositoryUpdater.activity"); //NOI18N
logger.setLevel(Level.FINEST);
logger.setUseParentHandlers(false);
logger.addHandler( new Handler() { //NOI18N
@Override
public void publish(LogRecord record) {
if( Level.FINEST.equals( record.getLevel() )
&& "START".equals(record.getMessage()) ) { //NOI18N
lock();
return;
}
if( Level.FINEST.equals( record.getLevel() )
&& "FINISHED".equals(record.getMessage()) ) { //NOI18N
unlock();
return;
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
}
示例10: forEnclosingClass
import java.util.logging.Logger; //导入方法依赖的package包/类
/** Returns a generic fluent logger for a class. */
public static FluentLogger forEnclosingClass() {
StackTraceElement caller = new Throwable().getStackTrace()[1];
Logger logger = Logger.getLogger(caller.getClassName());
logger.setUseParentHandlers(false);
logger.addHandler(new ConsoleHandler());
return new FluentLogger(logger, Level.OFF, Optional.empty());
}
示例11: HttpClient
import java.util.logging.Logger; //导入方法依赖的package包/类
@Inject HttpClient(Loggers loggers, HttpClientConfiguration config, JsonUtils jsonUtils, Gson gson) {
this.logger = loggers.get(getClass());
this.config = checkNotNull(config, "config");
this.jsonUtils = jsonUtils;
this.gson = gson;
ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("API HTTP Executor").build();
if (config.getThreads() > 0) {
this.executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(config.getThreads()));
} else {
this.executorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(threadFactory));
}
this.requestFactory = this.createRequestFactory();
// By default the google http client is very noisy on http errors,
// spitting out a long stack trace every time one try of a request
// fails. Disabling the parent handlers (removes default console
// handling) and adding our own handler that will only show the short
// message makes the error output much more manageable.
// See HttpRequest#986 for the offending line and HttpTransport#81 for
// the logger definition (it's package private so we can't access it
// directly).
final Logger httpLogger = Logger.getLogger(HttpTransport.class.getName());
httpLogger.setUseParentHandlers(false);
httpLogger.addHandler(new ConsoleHandler() {
@Override
public void publish(LogRecord record) {
String message = record.getMessage();
if (record.getThrown() != null) message += ": " + record.getThrown().toString();
HttpClient.this.logger.log(record.getLevel(), message);
}
});
}
示例12: deactivateConsoleOutput
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Deactivates console output for a given logger.
*
* @param loggerName
*/
public static void deactivateConsoleOutput(String loggerName) {
if (loggerName != null) {
Logger logger = loggers.get(loggerName);
if (logger != null) {
logger.setUseParentHandlers(false);
}
}
}
示例13: activateConsoleOutput
import java.util.logging.Logger; //导入方法依赖的package包/类
/**
* Activates console output for a given logger.
*
* @param loggerName
*/
public static void activateConsoleOutput(String loggerName) {
if (loggerName != null) {
Logger logger = loggers.get(loggerName);
if (logger != null) {
logger.setUseParentHandlers(true);
}
}
}
示例14: getLogger
import java.util.logging.Logger; //导入方法依赖的package包/类
protected Logger getLogger(C ctx) throws FileNotFoundException, IOException {
Logger result = ctx.getLogger("alvisnlp");
result.setLevel(logLevel);
result.setUseParentHandlers(false);
setHandlers(result, logFile);
for (Map.Entry<String,File> e : logFiles.entrySet()) {
Logger logger = ctx.getLogger("alvisnlp." + e.getKey());
logger.setLevel(logLevel);
setHandlers(logger, e.getValue());
}
return result;
}
示例15: getLogger
import java.util.logging.Logger; //导入方法依赖的package包/类
public Logger getLogger(ProcessingContext<Corpus> processingContext) throws FileNotFoundException {
Logger result = processingContext.getLogger("alvisnlp");
result.setLevel(Level.INFO);
result.setUseParentHandlers(false);
setHandlers(result, Level.INFO);
return result;
}