LOG处理SystemLogger.java

Wireshark 4.6 TCP 流图解析:3种拥塞控制算法可视化对比 本文深入解析Wireshark 4.6的TCP流图功能,通过可视化对比Reno、Cubic和BBR三种主流拥塞控制算法的性能特征。文章提供详细的实验环境搭建方法、流图分析工具使用技巧,以及算法调优建议,帮助网络工程师优化TCP性能。 阅读详情
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> import java.io.*; import java.util.*; import java.text.*; public class SystemLogger implements Runnable { public static int DEBUG = 0; public static int INFO = 1; public static int NOTICE = 2; public static int WARNING = 3; public static int ERROR = 4; public static int FATAL_ERROR = 5; public static int MIN_LEVEL = 0; public static int MAX_LEVEL = 5; public static int DAILY = 0; public static int HOURLY = 1; private static String[] LEVEL_DESC = { " ", " ", " ", "", " ", " ", }; private PrintWriter out; private int level = DEBUG; private DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); private boolean needToCloseOutput = false; private Thread thread = null; private String filePrefix = ""; private int switchingFrequency = DAILY; private Vector listeners = null; // --- Start of Singleton Pattern ----------------------- // private static SystemLogger instance = null; public static SystemLogger getInstance() { if (instance == null) { instance = new SystemLogger(); } return instance; } protected SystemLogger() { // Set default output to System.out: setOutput(System.out); } // --- End of Singleton Pattern ------------------------- // public synchronized void setOutput( String filePrefix, boolean autoSwitching, int frequency) { this.filePrefix = filePrefix; this.switchingFrequency = (frequency != DAILY && frequency != HOURLY) ? DAILY : frequency; if (autoSwitching) { if (thread == null) { thread = new Thread(this); thread.start(); } } else { if (thread != null) { Thread t = thread; thread = null; t.interrupt(); } setOutput(filePrefix ".log"); } } private synchronized void setOutput(String filename) { PrintWriter newOutput = null; try { newOutput = new PrintWriter(new FileOutputStream(filename, true)); } catch (IOException e) { logError("System logger failed to open file " filename, e); return; } if (out != null && needToCloseOutput) { logInfo("System logger output closed and switched to " filename); out.close(); } out = newOutput; needToCloseOutput = true; logInfo("System logger started with output to " filename); logInfo("System logger option (autoSwitching=" ((thread == null) ? "false" : "true, frequency=" ((switchingFrequency == DAILY) ? "daily" : ((switchingFrequency == HOURLY) ? "hourly" : "unknown"))) ")" ); } private synchronized void recycleOutput() { SimpleDateFormat df; if (switchingFrequency == DAILY) { df = new SimpleDateFormat("yyyy-MM-dd"); } else { df = new SimpleDateFormat("yyyy-MM-dd-HH"); } String filename = filePrefix "-" df.format(new Date()) ".log"; setOutput(filename); } public void run() { int currentDayOfMonth = -1; int currentHourOfDay = -1; for (;;) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); int dd = calendar.get(Calendar.DAY_OF_MONTH); int hh = calendar.get(Calendar.HOUR_OF_DAY); int mm = calendar.get(Calendar.MINUTE); int ss = calendar.get(Calendar.SECOND); int ms = calendar.get(Calendar.MILLISECOND); if ((switchingFrequency == DAILY && (dd != currentDayOfMonth)) || (switchingFrequency == HOURLY && (dd != currentDayOfMonth || hh != currentHourOfDay))) { recycleOutput(); } logDebug("Calendar dd=" dd " hh=" hh " mm=" mm " ss=" ss " ms=" ms); currentDayOfMonth = dd; currentHourOfDay = hh; int sleep; if (switchingFrequency == DAILY) { sleep = 86400000 - (((hh * 60 mm) * 60 ss) * 1000 ms); } else { sleep = 3600000 - ((mm * 60 ss) * 1000 ms); } sleep = 500; // add 0.5 sec. for tolerance. logDebug( "System logger will switch its output to a new file after " sleep " milliseconds."); try { Thread.sleep(sleep); } catch (InterruptedException e) { logDebug("System logger auto-switching thread interrupted"); } if (Thread.currentThread() != this.thread) { break; } } logDebug("System logger auto-switching thread terminated."); } public synchronized void setOutput(OutputStream os) { if (out != null && needToCloseOutput) { logInfo("System logger output closed."); out.close(); out = null; } out = new PrintWriter(os); needToCloseOutput = false; logInfo( "System logger started with output as " ((os == System.out) ? "System.out" : "OutputStream " os.toString())); } public synchronized void setOutput(PrintWriter writer) { if (out != null && needToCloseOutput) { logInfo("System logger output closed."); out.close(); out = null; } out = writer; needToCloseOutput = false; logInfo("System logger started with output as PrintWriter " writer.toString()); } public synchronized void close() { logInfo("System logger requested to be closed down."); if (thread != null) { Thread t = thread; thread = null; t.interrupt(); try { wait(500); } catch (InterruptedException e) {} } if (out != null && needToCloseOutput) { out.close(); out = null; } listeners = null; } /** Specifies the level of the messages to be logged. */ public void setLevel(int level) { this.level = level; } /** Returns the current logging level. @return the current logging level. */ public int getLevel() { return this.level; } /** Logs a message with the specified log level and associated exception. @param logLevel the level of the message. @param msg the message string. @param e an optional exception associated with the message. */ public void log(int logLevel, String msg, Exception e) { if (out == null || this.level > logLevel) { return; } logLevel = logLevel < MIN_LEVEL ? MIN_LEVEL : logLevel; logLevel = logLevel > MAX_LEVEL ? MAX_LEVEL : logLevel; String line; synchronized(this) { line = "# " dateFormat.format(new Date()) " " LEVEL_DESC[logLevel] " " msg; out.println(line); if (e != null) { e.printStackTrace(out); } out.flush(); } if (listeners != null) { SystemLoggerListener listener; SystemLoggerEvent evt = new SystemLoggerEvent(this, logLevel, msg, e, line); for (Enumeration en = ((Vector)listeners.clone()).elements(); en.hasMoreElements(); ) { try { listener = (SystemLoggerListener)en.nextElement(); listener.messageLogged(evt); } catch (Exception e1) {} } } } /** Logs a debug message with an exception. @param msg the message string @param e the excetpion. */ public void logDebug(String msg, Exception e) { log(DEBUG, msg, e); } /** Logs a debug message without an exception. @param msg the message string @param e the excetpion. */ public void logDebug(String msg) { log(DEBUG, msg, null); } /** Logs an info message with an exception. @param msg the message string @param e the excetpion. */ public void logInfo(String msg, Exception e) { log(INFO, msg, e); } /** Logs an info message without an exception. @param msg the message string @param e the excetpion. */ public void logInfo(String msg) { log(INFO, msg, null); } /** Logs a notice message with an exception. @param msg the message string @param e the excetpion. */ public void logNotice(String msg, Exception e) { log(NOTICE, msg, e); } /** Logs a notice message without an exception. @param msg the message string @param e the excetpion. */ public void logNotice(String msg) { log(NOTICE, msg, null); } /** Logs a warning message with an exception. @param msg the message string @param e the excetpion. */ public void logWarning(String msg, Exception e) { log(WARNING, msg, e); } /** Logs a warning message without an exception. @param msg the message string @param e the excetpion. */ public void logWarning(String msg) { log(WARNING, msg, null); } /** Logs an error message with an exception. @param msg the message string @param e the excetpion. */ public void logError(String msg, Exception e) { log(ERROR, msg, e); } /** Logs an error message without an exception. @param msg the message string @param e the excetpion. */ public void logError(String msg) { log(ERROR, msg, null); } /** Logs a fatal error message with an exception. @param msg the message string @param e the excetpion. */ public void logFatalError(String msg, Exception e) { log(FATAL_ERROR, msg, e); } /** Logs a fatal error message without an exception. @param msg the message string @param e the excetpion. */ public void logFatalError(String msg) { log(FATAL_ERROR, msg, null); } public synchronized void addSystemLoggerListener( SystemLoggerListener listener) { if (listeners == null) { listeners = new Vector(); } listeners.addElement(listener); } public void removeSystemLoggerListener( SystemLoggerListener listener) { if (listener != null) { listeners.removeElement(listener); } } }
gem5 prefetcher 最近在gem5上做预取实验,添加自己的预取算法,这里采用hardware stream prefetcher , 修改了几个bug才给实验调试通过,发文记录下实验过程。 gem5上添加自己的预取算法步骤: (1)路径gem5-master/configs/common/Caches.py下,开启预取:class L1Cache(Cache): assoc = 2 tag_late 阅读详情

相关推荐

2.6 SST的核心性能指标体系

本文构建了固态变压器(SST)的核心性能指标体系,涵盖电气性能、可靠性、经济性和环境适配性四大类指标。电气性能指标包括运行效率(≥97%)、功率密度(≥900kVA/m³)、谐波畸变率(≤3%)等关键参数;可靠性指标设定MTBF≥43800h、年均故障率≤1.2次/年等标准;经济性指标对比分析了初始购置成本(45-55万元)和全生命周期成本(48-55万元);环境适配性指标则明确了温度、海拔等工况要求。该体系采用量化公式和国标限值,为SST的性能测试、选型和优化提供了统一标准。

技术工作者 606

idea运行报日志冲突

问题描述: 日志冲突,解决: 全部删除,重新运行.

weixin_43076660的博客 572

Pinocchio 安装教程|机器人学的必备库

安装pinocchio,不要安装pip3 install pinocchio!

darcsdn 1663

【Java】异常处理 之 使用SLF4J 和 Logback

前面介绍了和Log4j这一对好基友,它们一个负责充当日志 API,一个负责实现日志底层,搭配使用非常便于开发。有的童鞋可能还听说过SLF4J和Logback。这两个东东看上去也像日志,它们又是啥?其实SLF4J类似,也是一个日志接口,而Logback类似于Log4j,是一个日志的实现。为什么有了和Log4j,又会蹦出来SLF4J和Logback?这是因为Java有着非常悠久的开源历史,不但OpenJDK本身是开源的,而且我们用到的第三方库,几乎全部都是开源的。

ihero的博客 504

python爬取巨潮资讯网所有股票年报数据

爬虫获取巨潮资讯网数据

qq_42752524的博客 6125

如何解决群晖Docker注册表查询失败/无法拉取镜像等问题

如何解决群晖Docker注册表查询失败/无法拉取镜像等问题

XiaoqiangClub的博客 1万+

东方通中间件SystemOutLogger.log报错

tomcat和websphere正常,但是使用东方通中间件会抛出java.lang.NullPointerException异常的情况

ruanyongcan1990的博客 1550

YOLO11优化:特征融合 | 金字塔稀疏 Transformer(PST)——一个轻量级、即插即用的模块 | 25年7月最新成果

我们提出金字塔稀疏 Transformer(PST)——一个轻量级、即插即用的模块,通过由粗到细的 token 选择机制和共享注意力参数,在大幅降低计算量的同时保留空间细节。

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1066

systemlog java_LOG处理SystemLogger.java

LOG处理SystemLogger.java(2007-04-05 23:13:18)import java.io.*;import java.util.*;import java.text.*;public class SystemLogger implements Runnable {public static int DEBUG = 0;public static int I...

weixin_39810901的博客 230

uniapp - 实现扫码功能自定义扫描二维码/条码界面+手电筒轻触照亮+扫码屏幕添加手动输入框,手机扫描二维码并跳转过程,调用手机原生摄像头进行扫码且自动识别执行事件(uniApp安卓苹果App端)

uniapp,app端,安卓app,苹果ios,uniapp扫码识别,二维码展示和扫码,uniapp如何实现扫码功能,uni-app实现扫码功能,二维码和一维码/条码扫描,UniApp实现扫描二维码,uniapp开发原生app页面的扫码功能,自定义扫码界面,uniapp怎么调用扫一扫功能,app自定义扫码界面,uniapp 自定义扫一扫页面,扫码手电筒功能,自定义扫描框,扫码报错怎么办,扫码黑屏,扫一扫摄像头黑屏,uniapp扫码原生插件,最新扫码组件,连续扫码,uniapp APP扫码,扫码后如何处理跳转

✅ 精选推荐文章 1万+

YOLOv8改进 | 卷积模块 | 用DWConv卷积替换Conv【轻量化网络】

YOLOv8改进,yolov8,yolov8创新,yolov8涨点

kay_545 7160

systemlog客户端 java_LOG处理SystemLogger.java

","",};private PrintWriter out;private int level = DEBUG;private DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");private boolean needToCloseOutput = false;private Thread thread = n...

weixin_30661579的博客 439

30.Labview如何读懂别人程序、修改程序?

之前写过一次教大家的文章,这次教大家如何学习别人的程序,和如何搭建一套适合自己的程序框架。这里事先说明一下:要想搭好程序框架,一定要先把自己的系统,逻辑是什么!这非常重要,是决定你程序的关键因素。废话不多扯,直接说重点。

关注我,更多技术问题欢迎私聊~ 2448

在项目中记录日志

最近写了几个接口和服务,发现自己在java基础部分的几个薄弱环节:         1.日志的记录。2.对于异常的捕获与处理。3.对应文件读写的综合运用,尤其是结合线程。4.webservice的写法模式还需要巩固5.Hessian的用法,有空总结一下。 下面就日志的记录做一下总结:         以前没有养成写规范日志的习惯,一直都用println语句输出控制台,上线之后,查看错误日志本

小小_一路走一路成长 903

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

7.1 Tomcat学习(日志记录器Logger)

日志记录器是一个组件,必须和某个servlet容器关联才能使用。 package org.apache.catalina; import java.beans.PropertyChangeListener; public interface Logger { //日志记录器可以记录5种类型的日志,用int型整数表示等级, public static final int FA

852

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Springboot项目启动报错java.lang.logback.core.joran.spi.Interpreter

Springboot项目启动报错java.lang.logback.core.joran.spi.Interpreter 刚开始以为是日志文件的jar包冲突,按照网上的教程,修改了jar包的冲突,结果还是不行,后来检查了一下配置文件中的数据库链接地址 最开始我这里连的是本机的数据库,想了一下我项目跑的数据库是服务器上的,把地址改掉就可以了 结论:日志文件的链接地址要于数据库链接地址同步 如有不正确的地方,欢迎指正,一起进步 ...

qq_30072161的博客 323

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

logback控制台不打印logger.info()日志

logback控制台突然不打印日志了 起因 import com.sun.istack.internal.logging.Logger; 昨天springboot项目打个jar包,说打不了第三方包,于是我就换了个 import org.apache.log4j.Logger; 打包成功。高兴。。。 那么问题来了 今天启动项目,swagger调试的时候发现不打印我要的日志了 代码:logger.info(""+"\r\n"+“token:”+token+"\r\n"+“user:”+admin.toStrin

zhh347713307的博客 7832

配置好Log4j之后,实例化Logger时报错

配置好Log4j之后,实例化Logger时报错 原因是导入Logger包时导入错误 改正后: 导入时要看清来源!!!

YYL525的博客 417

java 自带logger_Java原生日志 java.util.logging.Logger

这是个大标题在某些情况下写个简单的项目懒得引用Log4j的时候使用Java自带的日志也不错先来个示例:import java.util.logging.FileHandler;import java.util.logging.Level;import java.util.logging.Logger;import java.util.logging.SimpleFormatter;public c...

weixin_40004502的博客 262

merge 无效原因及解决方案

今天合并两个分支时发现,有些代码并没有合并成功。原因是分支问题分支结构如下 我们是在两个分支上开发,v4.0.1 和newVersion_sgd ,现在要将这两个分支合并到新分支v4.0.2上,结果发现v.4.0.1上有些代码并没有合并上来。原因是newVersion_sgd是从分支v4.0.1上来的,后面在v4.0.1上开发的代码就不能再合并到newVersion_sgd上了。 解决方法...

匿名攻城狮的博客 1万+

java logger 静态,java11教程--公共静态接口System.Logger

System.Logger实例记录将被路由到使用的基础日志框架的消息LoggerFinder。 System.Logger实例通常是System通过调用System.getLogger(loggerName) 或从类中 获取的System.getLogger(loggerName, bundle)。修饰符和类型 方法 描述String getName()返回此记录器的名称。boo...

weixin_39894914的博客 378

结合国际化使用Systsm.Logger

使用System.Logger的国际化功能,也就是使用System.getLogger("",ResourceBundle)来获取System.Logger对象 Test.java import java.util.*; import java.util.logging.*; import static java.lang.System.Logger.Level.*; public class Test { public static void main(String[] args) throws Exc

yaoguaiba579567的博客 253

Logger的解析使用

Logger的简单使用作为一个入世未深的小程序猿,在运行过程中程序崩溃看到满屏的谷歌原生的log日志脑子里有一万只草泥马飞过,然而,我们的成长必须站在巨人的肩膀上,大神已经封装好了一个perfect的打印日志类Logger给广大猿们带来了方便,下面是个人的一点理解和使用: 首先我们看一下原生的log日志: 如果你已经习惯了这种日志,那么只能说你太容易满足了,接下来看一下Logger的日志,没

luweicheng24的博客 1590

Java开源博客My-Blog之mysql容器重复初始化的严重bug修复过程

写在前面的话 《Docker+SpringBoot+Mybatis+thymeleaf的Java博客系统开源啦》 《Java开源博客My-Blog之docker容器组件化修改》 My Blog项目已经开源了两个多月,也收获了不少star,在这里谢谢各位朋友的建议及帮助。由于个人原因,这个开源项目最初的定位其实是一个docker技术与springboot框架整合的Java博客系统实战项目,...

Elinor2017的博客 243

spring boot 系统异常统一处理

1.系统异常捕获 @ControllerAdvice(annotations = {RestController.class}) public class GlobalExceptionHandler { private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); /** ...

金溪的博客 1115

Java 项目中异常的统一处理

1. 前言 Java中的异常处理,常用的处理方式,直接throw 一个异常对象,或者捕获catch一个异常,让程序继续执行,但是在一个项目中,这种简单处理异常的方式并不可取,因为在业务代码中直接抛出或者捕获异常,跟业务的耦合性都太高,而且代码冗余不利于维护;更好的处理方式,应该是利用切面编程的思想,自定义一个全局异常类,返回一个统一规范的异常信息; 2. 对Java中异常的理解 首先我们先理...

Zach的博客 3850
上一篇: Jsp JavaBean循序渐进教程(四)下
下一篇: Java语言编程中更新XML文档的常用方法
java169
博客等级 码龄19年 27粉丝 2568原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值