com.alibaba.dubbo.common.logger.Level Java Examples

The following examples show how to use com.alibaba.dubbo.common.logger.Level. 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: Logs.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String)context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (! User.ROOT.equals(role)) {
       context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #2
Source File: Logs.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String)context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (! User.ROOT.equals(role)) {
       context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #3
Source File: Log4jLoggerAdapter.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
private static Level fromLog4jLevel(org.apache.log4j.Level level) {
	if (level == org.apache.log4j.Level.ALL)
		return Level.ALL;
	if (level == org.apache.log4j.Level.TRACE)
		return Level.TRACE;
	if (level == org.apache.log4j.Level.DEBUG)
		return Level.DEBUG;
	if (level == org.apache.log4j.Level.INFO)
		return Level.INFO;
	if (level == org.apache.log4j.Level.WARN)
		return Level.WARN;
	if (level == org.apache.log4j.Level.ERROR)
		return Level.ERROR;
	// if (level == org.apache.log4j.Level.OFF)
		return Level.OFF;
}
 
Example #4
Source File: Logs.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String)context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (! User.ROOT.equals(role)) {
       context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #5
Source File: Log4jLoggerAdapter.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
private static org.apache.log4j.Level toLog4jLevel(Level level) {
    if (level == Level.ALL)
        return org.apache.log4j.Level.ALL;
    if (level == Level.TRACE)
        return org.apache.log4j.Level.TRACE;
    if (level == Level.DEBUG)
        return org.apache.log4j.Level.DEBUG;
    if (level == Level.INFO)
        return org.apache.log4j.Level.INFO;
    if (level == Level.WARN)
        return org.apache.log4j.Level.WARN;
    if (level == Level.ERROR)
        return org.apache.log4j.Level.ERROR;
    // if (level == Level.OFF)
    return org.apache.log4j.Level.OFF;
}
 
Example #6
Source File: JdkLoggerAdapter.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
private static Level fromJdkLevel(java.util.logging.Level level) {
    if (level == java.util.logging.Level.ALL)
        return Level.ALL;
    if (level == java.util.logging.Level.FINER)
        return Level.TRACE;
    if (level == java.util.logging.Level.FINE)
        return Level.DEBUG;
    if (level == java.util.logging.Level.INFO)
        return Level.INFO;
    if (level == java.util.logging.Level.WARNING)
        return Level.WARN;
    if (level == java.util.logging.Level.SEVERE)
        return Level.ERROR;
    // if (level == java.util.logging.Level.OFF)
    return Level.OFF;
}
 
Example #7
Source File: JdkLoggerAdapter.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
private static java.util.logging.Level toJdkLevel(Level level) {
    if (level == Level.ALL)
        return java.util.logging.Level.ALL;
    if (level == Level.TRACE)
        return java.util.logging.Level.FINER;
    if (level == Level.DEBUG)
        return java.util.logging.Level.FINE;
    if (level == Level.INFO)
        return java.util.logging.Level.INFO;
    if (level == Level.WARN)
        return java.util.logging.Level.WARNING;
    if (level == Level.ERROR)
        return java.util.logging.Level.SEVERE;
    // if (level == Level.OFF)
    return java.util.logging.Level.OFF;
}
 
Example #8
Source File: Logs.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String)context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (! User.ROOT.equals(role)) {
       context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #9
Source File: Log4jLoggerAdapter.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
private static org.apache.log4j.Level toLog4jLevel(Level level) {
	if (level == Level.ALL)
		return org.apache.log4j.Level.ALL;
	if (level == Level.TRACE)
		return org.apache.log4j.Level.TRACE;
	if (level == Level.DEBUG)
		return org.apache.log4j.Level.DEBUG;
	if (level == Level.INFO)
		return org.apache.log4j.Level.INFO;
	if (level == Level.WARN)
		return org.apache.log4j.Level.WARN;
	if (level == Level.ERROR)
		return org.apache.log4j.Level.ERROR;
	// if (level == Level.OFF)
		return org.apache.log4j.Level.OFF;
}
 
Example #10
Source File: LogsController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String) context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (!User.ROOT.equals(role)) {
        context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #11
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Level fromJdkLevel(java.util.logging.Level level) {
	if (level == java.util.logging.Level.ALL)
		return Level.ALL;
	if (level == java.util.logging.Level.FINER)
		return Level.TRACE;
	if (level == java.util.logging.Level.FINE)
		return Level.DEBUG;
	if (level == java.util.logging.Level.INFO)
		return Level.INFO;
	if (level == java.util.logging.Level.WARNING)
		return Level.WARN;
	if (level == java.util.logging.Level.SEVERE)
		return Level.ERROR;
	// if (level == java.util.logging.Level.OFF)
		return Level.OFF;
}
 
Example #12
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static java.util.logging.Level toJdkLevel(Level level) {
	if (level == Level.ALL)
		return java.util.logging.Level.ALL;
	if (level == Level.TRACE)
		return java.util.logging.Level.FINER;
	if (level == Level.DEBUG)
		return java.util.logging.Level.FINE;
	if (level == Level.INFO)
		return java.util.logging.Level.INFO;
	if (level == Level.WARN)
		return java.util.logging.Level.WARNING;
	if (level == Level.ERROR)
		return java.util.logging.Level.SEVERE;
	// if (level == Level.OFF)
		return java.util.logging.Level.OFF;
}
 
Example #13
Source File: Logs.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public boolean change(Map<String, Object> context) throws Exception {
    String contextLevel = (String)context.get("level");
    if (contextLevel == null || contextLevel.length() == 0) {
        context.put("message", getMessage("MissRequestParameters", "level"));
        return false;
    }
    if (! User.ROOT.equals(role)) {
       context.put("message", getMessage("HaveNoRootPrivilege"));
        return false;
    }
    Level level = Level.valueOf(contextLevel);
    if (level != LoggerFactory.getLevel()) {
        LoggerFactory.setLevel(level);
    }
    context.put("redirect", "/sysinfo/logs");
    return true;
}
 
Example #14
Source File: JdkLoggerAdapter.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
private static java.util.logging.Level toJdkLevel(Level level) {
	if (level == Level.ALL)
		return java.util.logging.Level.ALL;
	if (level == Level.TRACE)
		return java.util.logging.Level.FINER;
	if (level == Level.DEBUG)
		return java.util.logging.Level.FINE;
	if (level == Level.INFO)
		return java.util.logging.Level.INFO;
	if (level == Level.WARN)
		return java.util.logging.Level.WARNING;
	if (level == Level.ERROR)
		return java.util.logging.Level.SEVERE;
	// if (level == Level.OFF)
		return java.util.logging.Level.OFF;
}
 
Example #15
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Level fromJdkLevel(java.util.logging.Level level) {
	if (level == java.util.logging.Level.ALL)
		return Level.ALL;
	if (level == java.util.logging.Level.FINER)
		return Level.TRACE;
	if (level == java.util.logging.Level.FINE)
		return Level.DEBUG;
	if (level == java.util.logging.Level.INFO)
		return Level.INFO;
	if (level == java.util.logging.Level.WARNING)
		return Level.WARN;
	if (level == java.util.logging.Level.SEVERE)
		return Level.ERROR;
	// if (level == java.util.logging.Level.OFF)
		return Level.OFF;
}
 
Example #16
Source File: Log4jLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static org.apache.log4j.Level toLog4jLevel(Level level) {
	if (level == Level.ALL)
		return org.apache.log4j.Level.ALL;
	if (level == Level.TRACE)
		return org.apache.log4j.Level.TRACE;
	if (level == Level.DEBUG)
		return org.apache.log4j.Level.DEBUG;
	if (level == Level.INFO)
		return org.apache.log4j.Level.INFO;
	if (level == Level.WARN)
		return org.apache.log4j.Level.WARN;
	if (level == Level.ERROR)
		return org.apache.log4j.Level.ERROR;
	// if (level == Level.OFF)
		return org.apache.log4j.Level.OFF;
}
 
Example #17
Source File: Log4jLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static org.apache.log4j.Level toLog4jLevel(Level level) {
	if (level == Level.ALL)
		return org.apache.log4j.Level.ALL;
	if (level == Level.TRACE)
		return org.apache.log4j.Level.TRACE;
	if (level == Level.DEBUG)
		return org.apache.log4j.Level.DEBUG;
	if (level == Level.INFO)
		return org.apache.log4j.Level.INFO;
	if (level == Level.WARN)
		return org.apache.log4j.Level.WARN;
	if (level == Level.ERROR)
		return org.apache.log4j.Level.ERROR;
	// if (level == Level.OFF)
		return org.apache.log4j.Level.OFF;
}
 
Example #18
Source File: Log4jLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static org.apache.log4j.Level toLog4jLevel(Level level) {
	if (level == Level.ALL)
		return org.apache.log4j.Level.ALL;
	if (level == Level.TRACE)
		return org.apache.log4j.Level.TRACE;
	if (level == Level.DEBUG)
		return org.apache.log4j.Level.DEBUG;
	if (level == Level.INFO)
		return org.apache.log4j.Level.INFO;
	if (level == Level.WARN)
		return org.apache.log4j.Level.WARN;
	if (level == Level.ERROR)
		return org.apache.log4j.Level.ERROR;
	// if (level == Level.OFF)
		return org.apache.log4j.Level.OFF;
}
 
Example #19
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static java.util.logging.Level toJdkLevel(Level level) {
	if (level == Level.ALL)
		return java.util.logging.Level.ALL;
	if (level == Level.TRACE)
		return java.util.logging.Level.FINER;
	if (level == Level.DEBUG)
		return java.util.logging.Level.FINE;
	if (level == Level.INFO)
		return java.util.logging.Level.INFO;
	if (level == Level.WARN)
		return java.util.logging.Level.WARNING;
	if (level == Level.ERROR)
		return java.util.logging.Level.SEVERE;
	// if (level == Level.OFF)
		return java.util.logging.Level.OFF;
}
 
Example #20
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Level fromJdkLevel(java.util.logging.Level level) {
	if (level == java.util.logging.Level.ALL)
		return Level.ALL;
	if (level == java.util.logging.Level.FINER)
		return Level.TRACE;
	if (level == java.util.logging.Level.FINE)
		return Level.DEBUG;
	if (level == java.util.logging.Level.INFO)
		return Level.INFO;
	if (level == java.util.logging.Level.WARNING)
		return Level.WARN;
	if (level == java.util.logging.Level.SEVERE)
		return Level.ERROR;
	// if (level == java.util.logging.Level.OFF)
		return Level.OFF;
}
 
Example #21
Source File: JdkLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static java.util.logging.Level toJdkLevel(Level level) {
	if (level == Level.ALL)
		return java.util.logging.Level.ALL;
	if (level == Level.TRACE)
		return java.util.logging.Level.FINER;
	if (level == Level.DEBUG)
		return java.util.logging.Level.FINE;
	if (level == Level.INFO)
		return java.util.logging.Level.INFO;
	if (level == Level.WARN)
		return java.util.logging.Level.WARNING;
	if (level == Level.ERROR)
		return java.util.logging.Level.SEVERE;
	// if (level == Level.OFF)
		return java.util.logging.Level.OFF;
}
 
Example #22
Source File: Log4jLoggerAdapter.java    From dubbox with Apache License 2.0 6 votes vote down vote up
private static Level fromLog4jLevel(org.apache.log4j.Level level) {
	if (level == org.apache.log4j.Level.ALL)
		return Level.ALL;
	if (level == org.apache.log4j.Level.TRACE)
		return Level.TRACE;
	if (level == org.apache.log4j.Level.DEBUG)
		return Level.DEBUG;
	if (level == org.apache.log4j.Level.INFO)
		return Level.INFO;
	if (level == org.apache.log4j.Level.WARN)
		return Level.WARN;
	if (level == org.apache.log4j.Level.ERROR)
		return Level.ERROR;
	// if (level == org.apache.log4j.Level.OFF)
		return Level.OFF;
}
 
Example #23
Source File: Logs.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    long size;
    String content;
    String modified;
    File file = LoggerFactory.getFile();
    if (file != null && file.exists()) {
        FileInputStream fis = new FileInputStream(file);
        FileChannel channel = fis.getChannel();
        size = channel.size();
        ByteBuffer bb;
        if (size <= SHOW_LOG_LENGTH) {
            bb = ByteBuffer.allocate((int) size);
            channel.read(bb, 0);
        } else {
            int pos = (int) (size - SHOW_LOG_LENGTH);
            bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
            channel.read(bb, pos);
        }
        bb.flip();
        content = new String(bb.array()).replace("<", "&lt;").replace(">", "&gt;");
        modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(file.lastModified()));
    } else {
        size = 0;
        content = "";
        modified = "Not exist";
    }
    Level level = LoggerFactory.getLevel();
    context.put("name", file == null ? "" : file.getAbsoluteFile());
    context.put("size", String.valueOf(size));
    context.put("level", level == null ? "" : level);
    context.put("modified", modified);
    context.put("content", content);
}
 
Example #24
Source File: LogsController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
    prepare(request, response, model, "index", "logs");
    long size;
    String content;
    String modified;
    File file = LoggerFactory.getFile();
    if (file != null && file.exists()) {
        FileInputStream fis = new FileInputStream(file);
        FileChannel channel = fis.getChannel();
        size = channel.size();
        ByteBuffer bb;
        if (size <= SHOW_LOG_LENGTH) {
            bb = ByteBuffer.allocate((int) size);
            channel.read(bb, 0);
        } else {
            int pos = (int) (size - SHOW_LOG_LENGTH);
            bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
            channel.read(bb, pos);
        }
        bb.flip();
        content = new String(bb.array()).replace("<", "&lt;").replace(">", "&gt;");
        modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(file.lastModified()));
    } else {
        size = 0;
        content = "";
        modified = "Not exist";
    }
    Level level = LoggerFactory.getLevel();
    model.addAttribute("name", file == null ? "" : file.getAbsoluteFile());
    model.addAttribute("size", String.valueOf(size));
    model.addAttribute("level", level == null ? "" : level);
    model.addAttribute("modified", modified);
    model.addAttribute("content", content);
    return "sysinfo/screen/logs/index";
}
 
Example #25
Source File: Logs.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    long size;
    String content;
    String modified;
    File file = LoggerFactory.getFile();
    if (file != null && file.exists()) {
        FileInputStream fis = new FileInputStream(file);
        FileChannel channel = fis.getChannel();
        size = channel.size();
        ByteBuffer bb;
        if (size <= SHOW_LOG_LENGTH) {
            bb = ByteBuffer.allocate((int) size);
            channel.read(bb, 0);
        } else {
            int pos = (int) (size - SHOW_LOG_LENGTH);
            bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
            channel.read(bb, pos);
        }
        bb.flip();
        content = new String(bb.array()).replace("<", "&lt;").replace(">", "&gt;");
        modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(file.lastModified()));
    } else {
        size = 0;
        content = "";
        modified = "Not exist";
    }
    Level level = LoggerFactory.getLevel();
    context.put("name", file == null ? "" : file.getAbsoluteFile());
    context.put("size", String.valueOf(size));
    context.put("level", level == null ? "" : level);
    context.put("modified", modified);
    context.put("content", content);
}
 
Example #26
Source File: Log4j2LoggerAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static org.apache.logging.log4j.Level toLog4jLevel(Level level) {
    if (level == Level.ALL)
        return org.apache.logging.log4j.Level.ALL;
    if (level == Level.TRACE)
        return org.apache.logging.log4j.Level.TRACE;
    if (level == Level.DEBUG)
        return org.apache.logging.log4j.Level.DEBUG;
    if (level == Level.INFO)
        return org.apache.logging.log4j.Level.INFO;
    if (level == Level.WARN)
        return org.apache.logging.log4j.Level.WARN;
    if (level == Level.ERROR)
        return org.apache.logging.log4j.Level.ERROR;
    return org.apache.logging.log4j.Level.OFF;
}
 
Example #27
Source File: Log4j2LoggerAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void setLevel(Level level) {
    LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    Configuration config = ctx.getConfiguration();
    LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
    loggerConfig.setLevel(toLog4jLevel(level));
    ctx.updateLoggers();
}
 
Example #28
Source File: Log4j2LoggerAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public static Level fromLog4jLevel(org.apache.logging.log4j.Level level) {
    if (level == org.apache.logging.log4j.Level.ALL)
        return Level.ALL;
    if (level == org.apache.logging.log4j.Level.TRACE)
        return Level.TRACE;
    if (level == org.apache.logging.log4j.Level.DEBUG)
        return Level.DEBUG;
    if (level == org.apache.logging.log4j.Level.INFO)
        return Level.INFO;
    if (level == org.apache.logging.log4j.Level.WARN)
        return Level.WARN;
    if (level == org.apache.logging.log4j.Level.ERROR)
        return Level.ERROR;
    return Level.OFF;
}
 
Example #29
Source File: Logs.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public void index(Map<String, Object> context) throws Exception {
    long size;
    String content;
    String modified;
    File file = LoggerFactory.getFile();
    if (file != null && file.exists()) {
        FileInputStream fis = new FileInputStream(file);
        FileChannel channel = fis.getChannel();
        size = channel.size();
        ByteBuffer bb;
        if (size <= SHOW_LOG_LENGTH) {
            bb = ByteBuffer.allocate((int) size);
            channel.read(bb, 0);
        } else {
            int pos = (int) (size - SHOW_LOG_LENGTH);
            bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
            channel.read(bb, pos);
        }
        bb.flip();
        content = new String(bb.array()).replace("<", "&lt;").replace(">", "&gt;");
        modified = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(file.lastModified()));
    } else {
        size = 0;
        content = "";
        modified = "Not exist";
    }
    Level level = LoggerFactory.getLevel();
    context.put("name", file == null ? "" : file.getAbsoluteFile());
    context.put("size", String.valueOf(size));
    context.put("level", level == null ? "" : level);
    context.put("modified", modified);
    context.put("content", content);
}
 
Example #30
Source File: Slf4jLoggerAdapter.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public void setLevel(Level level) {
    this.level = level;
}