当前位置: 首页>>代码示例>>Java>>正文


Java Logger.getName方法代码示例

本文整理汇总了Java中java.util.logging.Logger.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.getName方法的具体用法?Java Logger.getName怎么用?Java Logger.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Logger的用法示例。


在下文中一共展示了Logger.getName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleAnnouncements

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void handleAnnouncements(LiveEvent event, JsonObject payload) {
	try {
		if (Files.notExists(Paths.get("payloads\\"))) {
			new File("payloads\\").mkdir();
		}

		Logger logger = Logger.getLogger("payload-announcement");
		FileHandler fh = new FileHandler("payloads\\" + logger.getName() + ".json");
		SimpleFormatter formatter = new SimpleFormatter();
		fh.setFormatter(formatter);

		logger.addHandler(fh);

		logger.log(Level.INFO, payload.toString());
	} catch (SecurityException | IOException e) {}
}
 
开发者ID:StreamerSpectrum,项目名称:BeamTeamDiscordBot,代码行数:17,代码来源:ConstellationManager.java

示例2: handleChannelFollowed

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void handleChannelFollowed(LiveEvent event, JsonObject payload) {
	try {
		if (Files.notExists(Paths.get("payloads\\"))) {
			new File("payloads\\").mkdir();
		}

		Logger logger = Logger.getLogger("payload-channelFollowed");
		FileHandler fh = new FileHandler("payloads\\" + logger.getName() + ".json");
		SimpleFormatter formatter = new SimpleFormatter();
		fh.setFormatter(formatter);

		logger.addHandler(fh);

		logger.log(Level.INFO, payload.toString());
	} catch (SecurityException | IOException e) {}
}
 
开发者ID:StreamerSpectrum,项目名称:BeamTeamDiscordBot,代码行数:17,代码来源:ConstellationManager.java

示例3: handleUserFollowed

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void handleUserFollowed(LiveEvent event, JsonObject payload) {
	try {
		if (Files.notExists(Paths.get("payloads\\"))) {
			new File("payloads\\").mkdir();
		}

		Logger logger = Logger.getLogger("payload-userFollowed");
		FileHandler fh = new FileHandler("payloads\\" + logger.getName() + ".json");
		SimpleFormatter formatter = new SimpleFormatter();
		fh.setFormatter(formatter);

		logger.addHandler(fh);

		logger.log(Level.INFO, payload.toString());
	} catch (SecurityException | IOException e) {}
}
 
开发者ID:StreamerSpectrum,项目名称:BeamTeamDiscordBot,代码行数:17,代码来源:ConstellationManager.java

示例4: TLLogRecorder

import java.util.logging.Logger; //导入方法依赖的package包/类
TLLogRecorder(Logger logger, TLEntity entity) {
    this.entity = entity;
    this.logger = logger;
    this.mapEvents = new MapEvents(entity);
    this.logEvents = new LogEvents();
    this.name = logger.getName();

    this.logger.addHandler(handler);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:10,代码来源:TLLogRecorder.java

示例5: debugLogger

import java.util.logging.Logger; //导入方法依赖的package包/类
static void debugLogger(Logger logger, Logger expectedParent, TestHandler handler) {
    final String logName = logger.getName();
    final String prefix = "    " + logName;
    System.err.println("Logger " + logName
            + " logged with bundle name " + handler.lastBundleName
            + " (" + handler.lastBundle + ")");
    System.err.println(prefix + ".getResourceBundleName() is "
            + logger.getResourceBundleName());
    System.err.println(prefix + ".getResourceBundle() is "
            + logger.getResourceBundle());
    final Logger parent = logger.getParent();
    final String pname = parent == null ? null : parent.getName();
    final String pclass = parent == null ? ""
            : ("(" + parent.getClass().getName() + ")");
    final String presn = parent == null ? null
            : parent.getResourceBundleName();
    final ResourceBundle pres = parent == null ? null
            : parent.getResourceBundle();
    System.err.println(prefix + ".getParent() is "
            + pname + (pname == null ? ""
                    : (" " + pclass + ": " + parent)));
    System.err.println("    expected parent is :" + expectedParent);
    System.err.println(prefix + ".parent.getResourceBundleName() is "
            + presn);
    System.err.println(prefix + ".parent.getResourceBundle() is "
            + pres);
    System.err.println("    expected parent getResourceBundleName() is "
            + expectedParent.getResourceBundleName());
    System.err.println("    expected parent.getResourceBundle() is "
            + expectedParent.getResourceBundle());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:TestSetResourceBundle.java

示例6: checkLoggerNames

import java.util.logging.Logger; //导入方法依赖的package包/类
static void checkLoggerNames(List<Logger> loggers) {
    Enumeration<String> names = LogManager.getLogManager().getLoggerNames();
    if (names instanceof Iterator) {
        for (Iterator<?> it = Iterator.class.cast(names); it.hasNext(); ) {
            try {
                it.remove();
                throw new RuntimeException("Iterator supports remove!");
            } catch (UnsupportedOperationException x) {
                System.out.println("OK: Iterator doesn't support remove.");
            }
        }
        // We're not supposed to come here, but if we do then we
        // need to rewind names...
        names = LogManager.getLogManager().getLoggerNames();
    }

    List<String> loggerNames = Collections.list(names);
    if (!loggerNames.contains("")) {
        throw new RuntimeException("\"\"" +
                " not found in " + loggerNames);
    }
    if (!loggerNames.contains("global")) {
        throw new RuntimeException("global" +
                " not found in " + loggerNames);
    }
    for (Logger l : loggers) {
        if (!loggerNames.contains(l.getName())) {
            throw new RuntimeException(l.getName() +
                    " not found in " + loggerNames);
        }
    }
    System.out.println("Got all expected logger names");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:TestLoggerNames.java

示例7: LogWrapperBase

import java.util.logging.Logger; //导入方法依赖的package包/类
protected LogWrapperBase( Logger logger )
{
    this.logger = logger ;
    this.loggerName = logger.getName( );
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:LogWrapperBase.java

示例8: run

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void run() {
    try {
        handler.setLevel(Level.FINEST);
        while (goOn) {
            Logger l;
            Logger foo = Logger.getLogger("foo");
            Logger bar = Logger.getLogger("foo.bar");
            for (long i=0; i < nextLong.longValue() + 100 ; i++) {
                if (!goOn) break;
                l = Logger.getLogger("foo.bar.l"+i);
                final ResourceBundle b = l.getResourceBundle();
                final String name = l.getResourceBundleName();
                if (b != null) {
                    if (!name.equals(b.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +b.getBaseBundleName());
                    }
                }
                Logger ll = Logger.getLogger(l.getName()+".bie.bye");
                ResourceBundle hrb;
                String hrbName;
                if (handler.getLevel() != Level.FINEST) {
                    throw new RuntimeException("Handler level is not finest: "
                            + handler.getLevel());
                }
                final int countBefore = handler.count;
                handler.reset();
                ll.setLevel(Level.FINEST);
                ll.addHandler(handler);
                ll.log(Level.FINE, "dummy {0}", this);
                ll.removeHandler(handler);
                final int countAfter = handler.count;
                if (countBefore == countAfter) {
                    throw new RuntimeException("Handler not called for "
                            + ll.getName() + "("+ countAfter +")");
                }
                hrb = handler.rb;
                hrbName = handler.rbName;
                if (name != null) {
                    // if name is not null, then it implies that it
                    // won't change, since setResourceBundle() cannot
                    // replace a non null name.
                    // Since we never set the resource bundle on 'll',
                    // then ll must inherit its resource bundle [name]
                    // from l - and therefor we should find it in
                    // handler.rb/handler.rbName
                    if (!name.equals(hrbName)) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrbName);
                    }
                    // here we know that hrbName is not null so hrb
                    // should not be null either.
                    if (!name.equals(hrb.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrb.getBaseBundleName());
                    }
                }

                // Make sure to refer to 'l' explicitly in order to
                // prevent eager garbage collecting before the end of
                // the test (JDK-8030192)
                if (!ll.getName().startsWith(l.getName())) {
                    throw new RuntimeException("Logger " + ll.getName()
                            + "does not start with expected prefix "
                            + l.getName());
                }

                getRBcount.incrementAndGet();
                if (!goOn) break;
                Thread.sleep(1);
            }
        }
   } catch (Exception x) {
       fail(x);
   }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:78,代码来源:TestLoggerBundleSync.java

示例9: testLoggableLevels

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:71,代码来源:RootLevelInConfigFile.java

示例10: loggerName

import java.util.logging.Logger; //导入方法依赖的package包/类
private static String loggerName(Logger logger) {
    String name = logger.getName();
    if (name == null) return "<anonymous>";
    if (name.isEmpty()) return "<RootLogger>";
    return "\"" + name + "\"";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestInferCaller.java

示例11: JdkLogger

import java.util.logging.Logger; //导入方法依赖的package包/类
JdkLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:5,代码来源:JdkLogger.java


注:本文中的java.util.logging.Logger.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。