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


Java Level类代码示例

本文整理汇总了Java中org.apache.logging.log4j.Level的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: logErrorAPI

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public static void logErrorAPI(Throwable error, Class<?> classFile) {
    StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: ");
    msg.append(error);
    StackTraceElement[] stackTrace = error.getStackTrace();
    if (stackTrace.length > 0) {
        msg.append(", ").append(stackTrace[0]);
    }

    logger.log(Level.ERROR, msg.toString());

    if (classFile != null) {
        msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain()
                .getCodeSource().getLocation());
        logger.log(Level.ERROR, msg.toString());
    }
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:17,代码来源:BCLog.java

示例2: setUp

import org.apache.logging.log4j.Level; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  meters = new HashMap<>();
  meters.put("total", getMeter(APPENDS_BASE_NAME.submetric("total")));
  meters.put("trace", getMeter(APPENDS_BASE_NAME.withTags("level", "trace")));
  meters.put("debug", getMeter(APPENDS_BASE_NAME.withTags("level", "debug")));
  meters.put("info", getMeter(APPENDS_BASE_NAME.withTags("level", "info")));
  meters.put("warn", getMeter(APPENDS_BASE_NAME.withTags("level", "warn")));
  meters.put("error", getMeter(APPENDS_BASE_NAME.withTags("level", "error")));
  meters.put("fatal", getMeter(APPENDS_BASE_NAME.withTags("level", "fatal")));
  meters.put("throwCount", getMeter(THROWABLES_BASE_NAME.submetric("total")));
  meters.put("throw[RuntimeException]", getMeter(THROWABLES_BASE_NAME
          .withTags("class", RuntimeException.class.getName())
  ));

  logger = LogManager.getLogger(Log4J2InstrumentationTest.class.getName());
  origLevel = logger.getLevel();
  setLogLevel(logger, Level.ALL);

}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:23,代码来源:Log4J2InstrumentationTest.java

示例3: main

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public static void main(String[] args) {
	final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	final Configuration config = ctx.getConfiguration();
	config.getLoggerConfig(strategy.Portfolio.class.getName()).setLevel(Level.WARN);
	ctx.updateLoggers(config);
	
	final CommonParam cp = ParamManager.getCommonParam("cu", TIME_FRAME.DAY, "19980101 000000", "20160916 170000");
	
	StrategyOptimizer so = new StrategyOptimizer(tester.RealStrategyTester.class);
	so.setInstrumentParam(cp.instrument, cp.tf);
	so.setTestDateRange((int) DateTimeHelper.Ldt2Long(cp.start_date), (int) DateTimeHelper.Ldt2Long(cp.end_date));
	int num = so.setStrategyParamRange(ChannelBreakStrategy.class, new Integer[]{4, 800, 2});
	System.out.println(num);
	so.StartOptimization();
	Set<Entry<Object[],Performances>> entryset = so.result_db.entrySet();
	for (Entry<Object[],Performances> entry : entryset) {
		for (Object obj : entry.getKey()) {
			System.out.print(obj + ",\t");
		}
		System.out.println("ProfitRatio: " + entry.getValue().ProfitRatio + "\tMaxDrawDown: " + entry.getValue().MaxDrawDown);
	}
}
 
开发者ID:zc8424,项目名称:QuantTester,代码行数:23,代码来源:OptimizeChannelBreak.java

示例4: execute

import org.apache.logging.log4j.Level; //导入依赖的package包/类
@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 = LogWriterLogger.logWriterNametoLog4jLevel(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);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:ChangeLogLevelFunction.java

示例5: requestPlayerTicket

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public static Ticket requestPlayerTicket(Object mod, String player, World world, Type type)
{
    ModContainer mc = getContainer(mod);
    if (mc == null)
    {
        FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
        return null;
    }
    if (playerTickets.get(player).size()>playerTicketLength)
    {
        FMLLog.warning("Unable to assign further chunkloading tickets to player %s (on behalf of mod %s)", player, mc.getModId());
        return null;
    }
    Ticket ticket = new Ticket(mc.getModId(),type,world,player);
    playerTickets.put(player, ticket);
    tickets.get(world).put("Forge", ticket);
    return ticket;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:ForgeChunkManager.java

示例6: decode

import org.apache.logging.log4j.Level; //导入依赖的package包/类
@Override
protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
    testMessageValidity(msg);
    ByteBuf payload = msg.payload().duplicate();
    if (payload.readableBytes() < 1)
    {
        FMLLog.log(Level.ERROR, "The FMLIndexedCodec has received an empty buffer on channel %s, likely a result of a LAN server issue. Pipeline parts : %s", ctx.channel().attr(NetworkRegistry.FML_CHANNEL), ctx.pipeline().toString());
    }
    byte discriminator = payload.readByte();
    Class<? extends A> clazz = discriminators.get(discriminator);
    if(clazz == null)
    {
        throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
    }
    A newMsg = clazz.newInstance();
    ctx.attr(INBOUNDPACKETTRACKER).get().set(new WeakReference<FMLProxyPacket>(msg));
    decodeInto(ctx, payload.slice(), newMsg);
    out.add(newMsg);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:FMLIndexedMessageToMessageCodec.java

示例7: updateLoggerLevel

import org.apache.logging.log4j.Level; //导入依赖的package包/类
/**
 * Looks up the logger in the logger factory,
 * and attempts to find the real logger instance
 * based on the underlying logging framework
 * and retrieve the logger object. Then, updates the level.
 * This functionality at this point is heavily dependant
 * on the log4j API.
 *
 * @param loggerName  the logger name
 * @param loggerLevel the logger level
 * @param additive    the additive nature of the logger
 * @param request     the request
 * @param response    the response
 * @throws Exception the exception
 */
@PostMapping(value = "/updateLoggerLevel")
@ResponseBody
public void updateLoggerLevel(@RequestParam final String loggerName,
                              @RequestParam final String loggerLevel,
                              @RequestParam(defaultValue = "false") final boolean additive,
                              final HttpServletRequest request,
                              final HttpServletResponse response) throws Exception {
    ensureEndpointAccessIsAuthorized(request, response);

    Assert.notNull(this.loggerContext);

    final Collection<LoggerConfig> loggerConfigs = getLoggerConfigurations();
    loggerConfigs.stream().
            filter(cfg -> cfg.getName().equals(loggerName))
            .forEachOrdered(cfg -> {
                cfg.setLevel(Level.getLevel(loggerLevel));
                cfg.setAdditive(additive);
            });
    this.loggerContext.updateLoggers();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:36,代码来源:LoggingConfigController.java

示例8: addPotionsAction

import org.apache.logging.log4j.Level; //导入依赖的package包/类
private void addPotionsAction(AttributeMap map) {
    List<PotionEffect> effects = new ArrayList<>();
    for (String p : map.getList(ACTION_POTION)) {
        String[] splitted = StringUtils.split(p, ',');
        if (splitted == null || splitted.length != 3) {
            InControl.logger.log(Level.ERROR, "Bad potion specifier '" + p + "'! Use <potion>,<duration>,<amplifier>");
            continue;
        }
        Potion potion = ForgeRegistries.POTIONS.getValue(new ResourceLocation(splitted[0]));
        if (potion == null) {
            InControl.logger.log(Level.ERROR, "Can't find potion '" + p + "'!");
            continue;
        }
        int duration = 0;
        int amplifier = 0;
        try {
            duration = Integer.parseInt(splitted[1]);
            amplifier = Integer.parseInt(splitted[2]);
        } catch (NumberFormatException e) {
            InControl.logger.log(Level.ERROR, "Bad duration or amplifier integer for '" + p + "'!");
            continue;
        }
        effects.add(new PotionEffect(potion, duration, amplifier));
    }
    if (!effects.isEmpty()) {
        actions.add(event -> {
            EntityLivingBase living = getHelper(event);
            for (PotionEffect effect : effects) {
                PotionEffect neweffect = new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier());
                living.addPotionEffect(neweffect);
            }
        });
    }
}
 
开发者ID:McJty,项目名称:InControl,代码行数:35,代码来源:SummonAidRule.java

示例9: removeStone

import org.apache.logging.log4j.Level; //导入依赖的package包/类
private void removeStone(World world, Random random, int x, int z) {
	int id = world.getBiomeGenForCoords(x, z).biomeID;
	Block block = Blocks.stone;

	if(id == 35 || id == 163 || id == 29 || id == 157 || id == 6 || id == 134 || id == 160 || id == 161 || id == 32 || id == 33) {
		block = Granite;
	} else if(id == 36 || id == 164 || id == 16 || id == 14 || id == 15 || id == 0 || id == 24 || id == 26) {
		block = Basalt;
	} else if(id == 2 || id == 1 || id == 7 || id == 129 || id == 5 || id == 30 || id == 11) {
		block = Limestone;
	} else if(id == 130 || id == 17 || id == 21 || id == 149 || id == 23 || id == 151 || id == 22 || id == 133 || id == 155 || id == 19 || id == 31 || id == 158 || id == 27) {
		block = Shale;
	} else if(id == 37 || id == 165 || id == 132 || id == 4 || id == 3 || id == 131 || id == 34 || id == 162 || id == 28 || id == 156 || id == 25) {
		block = Slate;
	} else if(id == 39 || id == 167 || id == 38 || id == 166 || id == 18 || id == 13 || id == 12 || id == 140) {
		block = Gneiss;
	} else {
		FMLLog.log(Level.ERROR, Technical.modName + ": TechnicalWorldGenerator could not find stone type for " + world.getBiomeGenForCoords(x, z).biomeName + " (id " + id + "). Please report this to the mod author(s)");
	}

	for(int y = 0; y < world.getActualHeight(); y++) {
		if(world.getBlock(x, y, z) == Blocks.stone)
			world.setBlock(x, y, z, block, 0, 0);
	}
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:26,代码来源:TechnicalWorldGenerator.java

示例10: syncConfig

import org.apache.logging.log4j.Level; //导入依赖的package包/类
private static void syncConfig(boolean load) {
	List<String> propOrder = new ArrayList<String>();
	try {
		Property prop = null;
		if(!config.isChild) {
			if(load) {
				config.load();
			}
		}
		
		biomeIDSpace = getIntegerConfigNode(config, prop, propOrder, Constants.CONFIG_CATEGORY_DIMENSIONS, "biomeIDSpace", "Biome ID for Space.", 100);
		
		config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);

           if (config.hasChanged())
           {
               config.save();
           }
	}catch (final Exception ex) {
		FMLLog.log(Level.ERROR, ex, "Trappist-1 has a problem loading it's config, this can have negative repercussions.");
	}
}
 
开发者ID:BlesseNtumble,项目名称:TRAPPIST-1,代码行数:23,代码来源:TPBiomeConfig.java

示例11: main

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public static void main(String[] args) {
	final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	final Configuration config = ctx.getConfiguration();
	config.getLoggerConfig(strategy.Portfolio.class.getName()).setLevel(Level.WARN);
	ctx.updateLoggers(config);
	
	final CommonParam cp = ParamManager.getCommonParam("i", TIME_FRAME.MIN15, "20080101 000000", "20160101 170000");
	
	StrategyOptimizer so = new StrategyOptimizer(tester.RealStrategyTester.class);
	so.setInstrumentParam(cp.instrument, cp.tf);
	so.setTestDateRange((int) DateTimeHelper.Ldt2Long(cp.start_date), (int) DateTimeHelper.Ldt2Long(cp.end_date));
	int num = so.setStrategyParamRange(MaPsarStrategy.class, new Integer[]{12, 500, 2}, new String[]{MA.MODE_EMA, MA.MODE_SMMA}, new APPLIED_PRICE[] {APPLIED_PRICE.PRICE_CLOSE, APPLIED_PRICE.PRICE_TYPICAL}, new Float[]{0.01f, 0.02f, 0.01f}, new Float[]{0.1f, 0.2f, 0.02f});
	System.out.println(num);
	so.StartOptimization();
	Set<Entry<Object[],Performances>> entryset = so.result_db.entrySet();
	for (Entry<Object[],Performances> entry : entryset) {
		for (Object obj : entry.getKey()) {
			System.out.print(obj + ",\t");
		}
		System.out.println("ProfitRatio: " + String.format("%.5f", entry.getValue().ProfitRatio) + "\tMaxDrawDown: " + entry.getValue().MaxDrawDown);
	}
}
 
开发者ID:zc8424,项目名称:QuantTester,代码行数:23,代码来源:OptimizeMaPsar.java

示例12: updateEntity

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public void updateEntity() {
	FMLLog.log(Level.INFO, "A");
	if(!worldObj.isRemote) {
		useItemToGetEnergy();
		if(canCraft()) {
			FMLLog.log(Level.INFO, "C");
			progress++;
			currentEnergy--;
			if(progress >= totalTime) {
				FMLLog.log(Level.INFO, "D");
				craftItem();
			}
		}
	}
	
	FMLLog.log(Level.INFO, "N");
	this.markDirty();
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:19,代码来源:TileEntityAutoWorkBench.java

示例13: overwriteAllText

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public static boolean overwriteAllText(File file, String text)
{
	if (file.exists())
	{
		if (!file.delete())
		{
			LogUtil.log(Level.ERROR, "Could not delete file to be overwritten: " + file.getPath());
			return false;
		}
	}

	try
	{
		Files.write(file.toPath(), text.getBytes(), StandardOpenOption.CREATE);
		return true;
	}
	catch (IOException e)
	{
		LogUtil.log(Level.ERROR, "IOException occurred saving " + file.getPath());
		LogUtil.log("");
		LogUtil.log(Level.ERROR, e.toString());
		return false;
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:25,代码来源:FileUtil.java

示例14: getInputStreamByName

import org.apache.logging.log4j.Level; //导入依赖的package包/类
@Override
protected InputStream getInputStreamByName(String resourceName) throws IOException
{
    try
    {
        return super.getInputStreamByName(resourceName);
    }
    catch (IOException ioe)
    {
        if ("pack.mcmeta".equals(resourceName))
        {
            FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName());
            return new ByteArrayInputStream(("{\n" +
                    " \"pack\": {\n"+
                    "   \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
                    "   \"pack_format\": 1\n"+
                    "}\n" +
                    "}").getBytes(Charsets.UTF_8));
        }
        else throw ioe;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:FMLFileResourcePack.java

示例15: preInit

import org.apache.logging.log4j.Level; //导入依赖的package包/类
public void preInit(FMLPreInitializationEvent event) {

		File directory = event.getModConfigurationDirectory();
		config = new Configuration(new File(directory.getPath(), "adventurers_toolbox.cfg"));
		Config.readConfig();

		MinecraftForge.EVENT_BUS.register(new HandpickHarvestHandler());
		MinecraftForge.EVENT_BUS.register(new SpecialToolAbilityHandler());
		MinecraftForge.EVENT_BUS.register(new HammerHandler());
		MinecraftForge.EVENT_BUS.register(new WeaponHandler());
		MinecraftForge.EVENT_BUS.register(new WorldHandler());

		ModMaterials.init();
		Toolbox.logger.log(Level.INFO,
				"Initialized tool part materials with " + Materials.head_registry.size() + " head materials, "
						+ Materials.haft_registry.size() + " haft materials, " + Materials.handle_registry.size()
						+ " handle materials, and " + Materials.adornment_registry.size() + " adornment materials");
		ModEntities.init();

		if (Loader.isModLoaded("tconstruct") && Config.ENABLE_TINKERS_COMPAT) {
			TConstructCompat.preInit();
		}
	}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:24,代码来源:CommonProxy.java


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