@Override
    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.isNumber(str[0])) {
                LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
            } else {
                int showLogLength = 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 <= showLogLength) {
                            bb = ByteBuffer.allocate((int) size);
                            filechannel.read(bb, 0);
                        } else {
                            int pos = (int) (size - showLogLength);
                            bb = ByteBuffer.allocate(showLogLength);
                            filechannel.read(bb, pos);
                        }
                        bb.flip();
                        String content = new String(bb.array())
                                .replace("<", "&lt;")
                                .replace(">", "&gt;")
                                .replace("\n", "<br/><br/>");
                        buf.append("\r\ncontent:").append(content);

                        buf.append("\r\nmodified:")
                                .append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                                        .format(new Date(file.lastModified())));
                        buf.append("\r\nsize:").append(size).append("\r\n");
                    } catch (Exception e) {
                        buf.append(e.getMessage());
                    }
                } else {
                    buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
                }
            }
        }
        buf.append("\r\nCURRENT LOG LEVEL:")
                .append(LoggerFactory.getLevel())
                .append("\r\nCURRENT LOG APPENDER:")
                .append(file == null ? "console" : file.getAbsolutePath());
        return buf.toString();
    }
@Test
    void testChangeLogLevel() throws RemotingException {
        mockChannel = mock(Channel.class);

        String result = log.telnet(mockChannel, "error");
        assertTrue(result.contains("\r\nCURRENT LOG LEVEL:ERROR"));
        String result2 = log.telnet(mockChannel, "warn");
        assertTrue(result2.contains("\r\nCURRENT LOG LEVEL:WARN"));
    }