FileHandler fileHandler = new FileHandler("app.log", true);

        fileHandler.setLevel(Level.ALL); // 文件将记录所有级别的日志
        fileHandler.setFormatter(new SimpleFormatter() {
            @Override
            public synchronized String format(LogRecord record) {
                // 自定义日志格式
                return String.format("%1$tF %1$tT [%2$s] %3$s %n", record.getMillis(), record.getLevel(), record.getMessage());
            }
        });
        logger.addHandler(fileHandler);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // 创建并设置Filter
    Filter filter = new Filter() {
        @Override
        public boolean isLoggable(LogRecord record) {
            // 这里可以添加过滤逻辑,例如只记录包含特定字符串的日志
            return record.getMessage().contains("important");
        }

https://www.laipuhuo.com/goodsDetail/0485abb0f7dc4fb4a2e96d0d...
https://www.laipuhuo.com/goodsDetail/0489593b66de41a7b348e658...
https://www.laipuhuo.com/goodsDetail/0494f4ef297747388cfba8a8...

https://www.laipuhuo.com/goodsDetail/01e6128347cd41d6a71fe7f5...
https://www.laipuhuo.com/goodsDetail/01ea87385e2d46fba71f79e0...
https://www.laipuhuo.com/goodsDetail/01EC88F9739A464B9CBAC6F5...
https://www.laipuhuo.com/goodsDetail/01ed3b6143214668897d8af1...
https://www.laipuhuo.com/goodsDetail/01f2a21598e9457a8d966206...
https://www.laipuhuo.com/goodsDetail/01f35571a1b644fca099b8a7...


已注销
1 声望0 粉丝