Java Code Examples for org.apache.log4j.Level#ERROR
The following examples show how to use
org.apache.log4j.Level#ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IngestUtilities.java From cognition with Apache License 2.0 | 6 votes |
public static Level levelFromString(String level) { String ulevel = level.toUpperCase(); if (ulevel.equals("ALL")) { return Level.ALL; } else if (ulevel.equals("DEBUG")) { return Level.DEBUG; } else if (ulevel.equals("ERROR")) { return Level.ERROR; } else if (ulevel.equals("FATAL")) { return Level.FATAL; } else if (ulevel.equals("INFO")) { return Level.INFO; } else if (ulevel.equals("OFF")) { return Level.OFF; } else if (ulevel.equals("TRACE")) { return Level.TRACE; } else if (ulevel.equals("WARN")) { return Level.WARN; } return Level.INFO; }
Example 2
Source File: Log4jSyslogBackLogHandler.java From syslog4j-graylog2 with GNU Lesser General Public License v2.1 | 6 votes |
protected static Level getLog4jLevel(int level) { switch (level) { case SyslogConstants.LEVEL_DEBUG: return Level.DEBUG; case SyslogConstants.LEVEL_INFO: return Level.INFO; case SyslogConstants.LEVEL_NOTICE: return Level.INFO; case SyslogConstants.LEVEL_WARN: return Level.WARN; case SyslogConstants.LEVEL_ERROR: return Level.ERROR; case SyslogConstants.LEVEL_CRITICAL: return Level.ERROR; case SyslogConstants.LEVEL_ALERT: return Level.ERROR; case SyslogConstants.LEVEL_EMERGENCY: return Level.FATAL; default: return Level.WARN; } }
Example 3
Source File: DBase.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void append (LoggingEvent e) { Level l = e.getLevel (); int lvl = -1; if (l == Level.WARN) { lvl = Log.WARNING; } else if (l == Level.ERROR) { lvl = Log.ERROR; } else if (l == Level.FATAL) { lvl = Log.FATAL; } if (lvl != -1) { String loggerName = e.getLoggerName (); if ((loggerName == null) || loggerName.startsWith ("org.springframework.jdbc")) { log.out (lvl, "jdbc", e.getRenderedMessage ()); } } }
Example 4
Source File: OptionConverter.java From logging-log4j2 with Apache License 2.0 | 6 votes |
public static Level convertLevel(org.apache.logging.log4j.Level level) { if (level == null) { return Level.ERROR; } switch (level.getStandardLevel()) { case FATAL: return Level.FATAL; case WARN: return Level.WARN; case INFO: return Level.INFO; case DEBUG: return Level.DEBUG; case TRACE: return Level.TRACE; case ALL: return Level.ALL; case OFF: return Level.OFF; default: return Level.ERROR; } }
Example 5
Source File: CommandLine.java From ofexport2 with Apache License 2.0 | 6 votes |
protected void setLogLevel(String logLevel) { Level level = Level.DEBUG; switch (logLevel.toLowerCase()) { case "debug": level = Level.DEBUG; break; case "info": level = Level.INFO; break; case "warn": level = Level.WARN; break; case "error": level = Level.ERROR; break; } org.apache.log4j.Logger.getLogger("org.psidnell").setLevel(level); LOGGER.debug("Log level is " + logLevel); }
Example 6
Source File: Log.java From h2o-2 with Apache License 2.0 | 6 votes |
public static void setLogLevel(int log_level) throws IllegalArgumentException { Level l; switch(log_level) { case 1: l = Level.TRACE; break; case 2: l = Level.DEBUG; break; case 3: l = Level.INFO; break; case 4: l = Level.WARN; break; case 5: l = Level.ERROR; break; case 6: l = Level.FATAL; break; default: throw new IllegalArgumentException("Log level " + log_level + " is invalid"); } _logger.setLevel(l); System.out.println("Set log level to " + l); _logger.info("Set log level to " + l); }
Example 7
Source File: MiniRPCBenchmark.java From hadoop with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.out.println("Benchmark: RPC session establishment."); if(args.length < 1) printUsage(); Configuration conf = new Configuration(); int count = Integer.parseInt(args[0]); if(args.length > 1) conf.set(KEYTAB_FILE_KEY, args[1]); if(args.length > 2) conf.set(USER_NAME_KEY, args[2]); boolean useDelegationToken = false; if(args.length > 3) useDelegationToken = args[3].equalsIgnoreCase("useToken"); Level l = Level.ERROR; if(args.length > 4) l = Level.toLevel(args[4]); MiniRPCBenchmark mb = new MiniRPCBenchmark(l); long elapsedTime = 0; if(useDelegationToken) { System.out.println( "Running MiniRPCBenchmark with delegation token authentication."); elapsedTime = mb.runMiniBenchmarkWithDelegationToken( conf, count, KEYTAB_FILE_KEY, USER_NAME_KEY); } else { String auth = SecurityUtil.getAuthenticationMethod(conf).toString(); System.out.println( "Running MiniRPCBenchmark with " + auth + " authentication."); elapsedTime = mb.runMiniBenchmark( conf, count, KEYTAB_FILE_KEY, USER_NAME_KEY); } System.out.println(org.apache.hadoop.util.VersionInfo.getVersion()); System.out.println("Number of connects: " + count); System.out.println("Average connect time: " + ((double)elapsedTime/count)); }
Example 8
Source File: LoggingEventTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Tests LoggingEvent.level. * @deprecated */ public void testLevel() { Category root = Logger.getRootLogger(); Priority info = Level.INFO; String catName = Logger.class.toString(); LoggingEvent event = new LoggingEvent( catName, root, 0L, info, "Hello, world.", null); Priority error = Level.ERROR; event.level = error; assertEquals(Level.ERROR, event.level); }
Example 9
Source File: LevelMatchFilterTestCase.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void deny() throws Exception { // set up appender Layout layout = new SimpleLayout(); Appender appender = new FileAppender(layout, DENY_FILE, false); // create LevelMatchFilter, set to deny matches LevelMatchFilter matchFilter = new LevelMatchFilter(); matchFilter.setAcceptOnMatch(false); // attach match filter to appender appender.addFilter(matchFilter); // set appender on root and set level to debug root.addAppender(appender); root.setLevel(Level.TRACE); Level[] levelArray = new Level[] {Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; for (int x = 0; x < levelArray.length; x++) { // set the level to match matchFilter.setLevelToMatch(levelArray[x].toString()); common("pass " + x + "; filter set to deny only " + levelArray[x].toString() + " msgs"); } Transformer.transform(DENY_FILE, DENY_FILTERED, new LineNumberFilter()); assertTrue(Compare.compare(DENY_FILTERED, DENY_WITNESS)); }
Example 10
Source File: LevelMatchFilterTestCase.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void accept() throws Exception { // set up appender Layout layout = new SimpleLayout(); Appender appender = new FileAppender(layout, ACCEPT_FILE, false); // create LevelMatchFilter LevelMatchFilter matchFilter = new LevelMatchFilter(); // attach match filter to appender appender.addFilter(matchFilter); // attach DenyAllFilter to end of filter chain to deny neutral // (non matching) messages appender.addFilter(new DenyAllFilter()); // set appender on root and set level to debug root.addAppender(appender); root.setLevel(Level.TRACE); Level[] levelArray = new Level[] {Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; for (int x = 0; x < levelArray.length; x++) { // set the level to match matchFilter.setLevelToMatch(levelArray[x].toString()); common("pass " + x + "; filter set to accept only " + levelArray[x].toString() + " msgs"); } Transformer.transform(ACCEPT_FILE, ACCEPT_FILTERED, new LineNumberFilter()); assertTrue(Compare.compare(ACCEPT_FILTERED, ACCEPT_WITNESS)); }
Example 11
Source File: LoggerPreference.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private static Level getLevelForId(String levelId) { switch (levelId) { case LEVEL_ALL: return Level.ALL; case LEVEL_INFO: return Level.INFO; case LEVEL_WARN: return Level.WARN; case LEVEL_ERROR: return Level.ERROR; } return Level.INFO; }
Example 12
Source File: TajoLogEventCounter.java From tajo with Apache License 2.0 | 5 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); String levelStr = level.toString(); if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) { counts.incr(INFO); } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) { counts.incr(WARN); } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) { counts.incr(ERROR); } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) { counts.incr(FATAL); } }
Example 13
Source File: ThumbnailServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void append(final LoggingEvent loggingEvent) { if(loggingEvent.getLevel() == Level.ERROR) { log.add(loggingEvent); } }
Example 14
Source File: MainWindow.java From ripme with MIT License | 5 votes |
private void setLogLevel(String level) { Level newLevel = Level.ERROR; level = level.substring(level.lastIndexOf(' ') + 1); switch (level) { case "Debug": newLevel = Level.DEBUG; break; case "Info": newLevel = Level.INFO; break; case "Warn": newLevel = Level.WARN; break; case "Error": newLevel = Level.ERROR; break; } Logger.getRootLogger().setLevel(newLevel); LOGGER.setLevel(newLevel); ConsoleAppender ca = (ConsoleAppender) Logger.getRootLogger().getAppender("stdout"); if (ca != null) { ca.setThreshold(newLevel); } FileAppender fa = (FileAppender) Logger.getRootLogger().getAppender("FILE"); if (fa != null) { fa.setThreshold(newLevel); } }
Example 15
Source File: DBase.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public int decide (LoggingEvent e) { Level l = e.getLevel (); if ((l == Level.WARN) || (l == Level.ERROR) || (l == Level.FATAL)) { return Filter.ACCEPT; } return Filter.NEUTRAL; }
Example 16
Source File: Log.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public int decide (LoggingEvent e) { Level l = e.getLevel (); if ((l == Level.DEBUG) || (l == Level.INFO) || (l == Level.WARN) || (l == Level.ERROR) || (l == Level.FATAL)) { return Filter.ACCEPT; } return Filter.NEUTRAL; }
Example 17
Source File: HBaseSITestEnv.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public HBaseSITestEnv(){ this(Level.ERROR); }
Example 18
Source File: ConfigManageController.java From wind-im with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/updateConfig") @ResponseBody public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (!isManager(siteUserId)) { throw new UserPermissionException("Current user is not a manager"); } Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); logger.info("siteUserId={} update config={}", siteUserId, dataMap); Map<Integer, String> configMap = new HashMap<Integer, String>(); if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) { configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) { configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) { configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) { configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, trim(dataMap.get("group_members_count"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) { configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path"))); } if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) { configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo")); } if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) { configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status")); } if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) { configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status")); } if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) { configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status")); } if (StringUtils.isNotEmpty(dataMap.get("add_friends_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_FRIEND_REQUEST_VALUE, dataMap.get("add_friends_status")); } if (StringUtils.isNotEmpty(dataMap.get("create_groups_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_CREATE_GROUP_VALUE, dataMap.get("create_groups_status")); } if (StringUtils.isNotEmpty(dataMap.get("group_qrcode_expire_time"))) { configMap.put(ConfigProto.ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE, dataMap.get("group_qrcode_expire_time")); } if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) { configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status")); } if (StringUtils.isNotEmpty(dataMap.get("log_level"))) { String logLevel = dataMap.get("log_level"); configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel); Level level = Level.INFO; if ("DEBUG".equalsIgnoreCase(logLevel)) { level = Level.DEBUG; } else if ("ERROR".equalsIgnoreCase(logLevel)) { level = Level.ERROR; } // 更新日志级别 AkxLog4jManager.setLogLevel(level); } // 普通管理员无权限 if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) { configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager"))); } if (configManageService.updateSiteConfig(siteUserId, configMap)) { return SUCCESS; } } catch (InvalidProtocolBufferException e) { logger.error("update site config error", e); } catch (UserPermissionException u) { logger.error("update site config error : " + u.getMessage()); return NO_PERMISSION; } return ERROR; }
Example 19
Source File: ConfigManageController.java From openzaly with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/updateConfig") @ResponseBody public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (!isManager(siteUserId)) { throw new UserPermissionException("Current user is not a manager"); } Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); logger.info("siteUserId={} update config={}", siteUserId, dataMap); Map<Integer, String> configMap = new HashMap<Integer, String>(); if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) { configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) { configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) { configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) { configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, trim(dataMap.get("group_members_count"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) { configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path"))); } if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) { configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo")); } if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) { configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status")); } if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) { configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status")); } if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) { configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status")); } if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) { configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status")); } if (StringUtils.isNotEmpty(dataMap.get("log_level"))) { String logLevel = dataMap.get("log_level"); configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel); Level level = Level.INFO; if ("DEBUG".equalsIgnoreCase(logLevel)) { level = Level.DEBUG; } else if ("ERROR".equalsIgnoreCase(logLevel)) { level = Level.ERROR; } // 更新日志级别 AkxLog4jManager.setLogLevel(level); } // 普通管理员无权限 if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) { configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager"))); } if (configManageService.updateSiteConfig(siteUserId, configMap)) { return SUCCESS; } } catch (InvalidProtocolBufferException e) { logger.error("update site config error", e); } catch (UserPermissionException u) { logger.error("update site config error : " + u.getMessage()); return NO_PERMISSION; } return ERROR; }
Example 20
Source File: MemcachedCache.java From lsmtree with Apache License 2.0 | 4 votes |
MemcachedCache( final MemcachedClient memcache, final InetSocketAddress address, final String prefix, final Stringifier<K> keyStringifier, final Serializer<V> valueSerializer ) throws IOException { this.memcache = memcache; this.prefix = prefix; this.keyStringifier = keyStringifier; this.host = address; valueTranscoder = new Transcoder<V>() { @Override public boolean asyncDecode(CachedData cachedData) { return false; } @Override public CachedData encode(V v) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); try { valueSerializer.write(v, out); return identityTranscoder.encode(out.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } } @Override public V decode(CachedData cachedData) { byte[] bytes = identityTranscoder.decode(cachedData); ByteArrayDataInput in = ByteStreams.newDataInput(bytes); try { return valueSerializer.read(in); } catch (IOException e) { throw new RuntimeException(e); } } @Override public int getMaxSize() { return Integer.MAX_VALUE; } }; final Thread addFutureChecker = new Thread( new FutureQueueChecker(run, addFutureQueue, "memcached add failed, key already exists in cache", Level.INFO), "addFutureChecker" ); addFutureChecker.setDaemon(true); addFutureChecker.start(); final Thread setFutureChecker = new Thread( new FutureQueueChecker(run, setFutureQueue, "memcached set failed, this should never happen", Level.ERROR), "setFutureChecker" ); setFutureChecker.setDaemon(true); setFutureChecker.start(); }