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


Java LoggerFactory.getFile方法代码示例

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


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

示例1: index

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:Logs.java

示例2: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0 ;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    }else {
        String str[] = message.split(" ");
        if (! StringUtils.isInteger(str[0])){
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
            
            if (file != null && file.exists()) {
                try{
                    FileInputStream fis = new FileInputStream(file);
                    try {
                     FileChannel filechannel = fis.getChannel();
                     try {
                      size = filechannel.size();
                      ByteBuffer bb;
                      if (size <= SHOW_LOG_LENGTH) {
                          bb = ByteBuffer.allocate((int) size);
                          filechannel.read(bb, 0);
                      } else {
                          int pos = (int) (size - SHOW_LOG_LENGTH);
                          bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                          filechannel.read(bb, pos);
                      }
                      bb.flip();
                      String content = new String(bb.array()).replace("<", "&lt;")
                      .replace(">", "&gt;").replace("\n", "<br/><br/>");
                      buf.append("\r\ncontent:"+content);
                      
                      buf.append("\r\nmodified:"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                      .format(new Date(file.lastModified()))));
                      buf.append("\r\nsize:"+size +"\r\n");
                     } finally {
                     	filechannel.close();
                     }
                    } finally {
                    	fis.close();
                    }
                }catch (Exception e) {
                    buf.append(e.getMessage());
                }
            }else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:"+ LoggerFactory.getLevel())
    .append("\r\nCURRENT LOG APPENDER:"+ (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:57,代码来源:LogTelnetHandler.java

示例3: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0 ;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    }else {
        String str[] = message.split(" ");
        if (! StringUtils.isInteger(str[0])){
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
            
            if (file != null && file.exists()) {
                try{
                    FileInputStream fis = new FileInputStream(file);
                    FileChannel filechannel = fis.getChannel();
                    size = filechannel.size();
                    ByteBuffer bb;
                    if (size <= SHOW_LOG_LENGTH) {
                        bb = ByteBuffer.allocate((int) size);
                        filechannel.read(bb, 0);
                    } else {
                        int pos = (int) (size - SHOW_LOG_LENGTH);
                        bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                        filechannel.read(bb, pos);
                    }
                    bb.flip();
                    String content = new String(bb.array()).replace("<", "&lt;")
                    .replace(">", "&gt;").replace("\n", "<br/><br/>");
                    buf.append("\r\ncontent:"+content);
                    
                    buf.append("\r\nmodified:"+(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                    .format(new Date(file.lastModified()))));
                    buf.append("\r\nsize:"+size +"\r\n");
                }catch (Exception e) {
                    buf.append(e.getMessage());
                }
            }else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:"+ LoggerFactory.getLevel())
    .append("\r\nCURRENT LOG APPENDER:"+ (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:LogTelnetHandler.java

示例4: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0;
    File file = LoggerFactory.getFile();
    StringBuilder buf = new StringBuilder();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    } else {
        String str[] = message.split(" ");
        if (!StringUtils.isInteger(str[0])) {
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);

            if (file != null && file.exists()) {
                try {
                    try (FileInputStream fis = new FileInputStream(file)) {
                        try (FileChannel filechannel = fis.getChannel()) {
                            size = filechannel.size();
                            ByteBuffer bb;
                            if (size <= SHOW_LOG_LENGTH) {
                                bb = ByteBuffer.allocate((int) size);
                                filechannel.read(bb, 0);
                            } else {
                                int pos = (int) (size - SHOW_LOG_LENGTH);
                                bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                                filechannel.read(bb, pos);
                            }
                            bb.flip();
                            String content = new String(bb.array()).replace("<", "&lt;")
                                    .replace(">", "&gt;").replace("\n", "<br/><br/>");
                            buf.append("\r\ncontent:" + content);

                            buf.append("\r\nmodified:" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                                    .format(new Date(file.lastModified()))));
                            buf.append("\r\nsize:" + size + "\r\n");
                        }
                    }
                } catch (Exception e) {
                    buf.append(e.getMessage());
                }
            } else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:" + LoggerFactory.getLevel())
            .append("\r\nCURRENT LOG APPENDER:" + (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:51,代码来源:LogTelnetHandler.java

示例5: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
public String telnet(Channel channel, String message) {
    long size;
    File file = LoggerFactory.getFile();
    StringBuilder buf = new StringBuilder();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    } else {
        String str[] = message.split(" ");
        if (!StringUtils.isInteger(str[0])) {
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);

            if (file != null && file.exists()) {
                try {
                    FileInputStream fis = new FileInputStream(file);
                    FileChannel filechannel = fis.getChannel();
                    size = filechannel.size();
                    ByteBuffer bb;
                    if (size <= SHOW_LOG_LENGTH) {
                        bb = ByteBuffer.allocate((int) size);
                        filechannel.read(bb, 0);
                    } else {
                        int pos = (int) (size - SHOW_LOG_LENGTH);
                        bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                        filechannel.read(bb, pos);
                    }
                    bb.flip();
                    String content = new String(bb.array()).replace("<", "&lt;")
                            .replace(">", "&gt;").replace("\n", "<br/><br/>");
                    buf.append("\r\ncontent:" + content);

                    buf.append("\r\nmodified:" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                            .format(new Date(file.lastModified()))));
                    buf.append("\r\nsize:" + size + "\r\n");
                } catch (Exception e) {
                    buf.append(e.getMessage());
                }
            } else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:" + LoggerFactory.getLevel())
            .append("\r\nCURRENT LOG APPENDER:" + (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:50,代码来源:LogTelnetHandler.java

示例6: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    } else {
        String str[] = message.split(" ");
        if (!StringUtils.isInteger(str[0])) {
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);

            if (file != null && file.exists()) {
                try {
                    FileInputStream fis = new FileInputStream(file);
                    try {
                        FileChannel filechannel = fis.getChannel();
                        try {
                            size = filechannel.size();
                            ByteBuffer bb;
                            if (size <= SHOW_LOG_LENGTH) {
                                bb = ByteBuffer.allocate((int) size);
                                filechannel.read(bb, 0);
                            } else {
                                int pos = (int) (size - SHOW_LOG_LENGTH);
                                bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                                filechannel.read(bb, pos);
                            }
                            bb.flip();
                            String content = new String(bb.array()).replace("<", "&lt;")
                                    .replace(">", "&gt;").replace("\n", "<br/><br/>");
                            buf.append("\r\ncontent:" + content);

                            buf.append("\r\nmodified:" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                                    .format(new Date(file.lastModified()))));
                            buf.append("\r\nsize:" + size + "\r\n");
                        } finally {
                            filechannel.close();
                        }
                    } finally {
                        fis.close();
                    }
                } catch (Exception e) {
                    buf.append(e.getMessage());
                }
            } else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:" + LoggerFactory.getLevel())
            .append("\r\nCURRENT LOG APPENDER:" + (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:57,代码来源:LogTelnetHandler.java

示例7: telnet

import com.alibaba.dubbo.common.logger.LoggerFactory; //导入方法依赖的package包/类
public String telnet(Channel channel, String message) {
    long size = 0;
    File file = LoggerFactory.getFile();
    StringBuffer buf = new StringBuffer();
    if (message == null || message.trim().length() == 0) {
        buf.append("EXAMPLE: log error / log 100");
    } else {
        String str[] = message.split(" ");
        if (!StringUtils.isInteger(str[0])) {
            LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
        } else {
            int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);

            if (file != null && file.exists()) {
                try {
                    FileInputStream fis = new FileInputStream(file);
                    FileChannel filechannel = fis.getChannel();
                    size = filechannel.size();
                    ByteBuffer bb;
                    if (size <= SHOW_LOG_LENGTH) {
                        bb = ByteBuffer.allocate((int) size);
                        filechannel.read(bb, 0);
                    } else {
                        int pos = (int) (size - SHOW_LOG_LENGTH);
                        bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                        filechannel.read(bb, pos);
                    }
                    bb.flip();
                    String content = new String(bb.array()).replace("<", "&lt;")
                            .replace(">", "&gt;").replace("\n", "<br/><br/>");
                    buf.append("\r\ncontent:" + content);

                    buf.append("\r\nmodified:" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                            .format(new Date(file.lastModified()))));
                    buf.append("\r\nsize:" + size + "\r\n");
                } catch (Exception e) {
                    buf.append(e.getMessage());
                }
            } else {
                size = 0;
                buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
            }
        }
    }
    buf.append("\r\nCURRENT LOG LEVEL:" + LoggerFactory.getLevel())
            .append("\r\nCURRENT LOG APPENDER:" + (file == null ? "console" : file.getAbsolutePath()));
    return buf.toString();
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:49,代码来源:LogTelnetHandler.java


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