本文整理汇总了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());
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
});
}
}
示例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);
}
}
示例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.");
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
示例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;
}
}
示例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();
}
}