热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

一般来说,管理调试消息的更好方法是什么?-Abetterwaytomanagedebugmessagesingeneral?

thatmaybeadumbquestionbutIhaveaquitelargejavaprogramthatimdebuggingusingtheol

that may be a dumb question... but I have a quite large java program that i'm debugging using the old System.err.println method, like I do using print* in any other language...

这可能是一个愚蠢的问题...但我有一个非常大的java程序,我正在使用旧的System.err.println方法进行调试,就像我在任何其他语言中使用print *一样...

But after a while, I've so many of them, I don't know how to manage them (and sometimes I put twice the same message concatenated with other information making it even harder...)...(and suppressing/finding them in the end is sometimes not trivial

但过了一段时间,我有很多这样的人,我不知道如何管理它们(有时我把两次相同的信息与其他信息联系在一起使得它更难......)......(并且压制/最终找到它们有时并非微不足道

I don't know how to be more rigourous... Do you have like a kind of magic token ? do you always print out the location of the println...

我不知道如何更加严谨......你有没有像一种神奇的象征?你总是打印出println的位置......

If you've any java tool, I'd consider them but best-practices in general would be great...

如果你有任何java工具,我会考虑它们,但一般的最佳实践会很棒......

5 个解决方案

#1


Perhaps give logging a try?

也许尝试登录?

Rather to piping messages out to standard output, have the logger take care of the logging for you. Also, being able to set different logging levels will allow for varying granularity for the log messages which are recorded.

而是将消息传递给标准输出,让记录器为您处理日志记录。此外,能够设置不同的日志记录级别将允许记录的日志消息的粒度变化。

#2


For java you should try log4j. With log4j you can set levels (TRACE, DEBUG, INFO, WARN, ERROR and FATAL) for the messages. You can choose (and change) the output of the log messages, like show the logs in the console, save in a file, ...

对于java,你应该尝试log4j。使用log4j,您可以为消息设置级别(TRACE,DEBUG,INFO,WARN,ERROR和FATAL)。您可以选择(并更改)日志消息的输出,例如在控制台中显示日志,保存在文件中,...

And you can configure the message formatting (show hour, show name of the class, ...).

您可以配置消息格式(显示小时,显示类的名称,...)。

You should try commons logging which works as an interface for the logging tools like log4j.

您应该尝试使用commons日志记录作为日志工具(如log4j)的接口。

#3


If you're using Eclipse you can use the "systrace" template (type systrace then ctrl+space). You edit the template to include file name, line number, etc (although the line number will be wrong if you move lines, there isn't a pretty macro like in C/C++)

如果您正在使用Eclipse,则可以使用“systrace”模板(键入systrace,然后键入ctrl + space)。您编辑模板以包含文件名,行号等(尽管如果移动行,行号将是错误的,但在C / C ++中没有漂亮的宏)

On the other hand, you should be using a logging framework like java's build in logging, commons-logging, or log4j ... for LOGGING and you should be using a DEBUGGER like Eclipse for debugging.

另一方面,您应该使用日志记录框架,例如java的日志记录,公共日志记录或log4j ...用于LOGGING,您应该使用像Eclipse这样的DEBUGGER进行调试。

#4


Yes - I always print location of the print. It was possible even in C with LINE macro. Try log4j it also prints the location of everything.

是的 - 我总是打印出印刷品的位置。即使在带有LINE宏的C中也是如此。尝试log4j它还会打印所有内容的位置。

#5


Eclipse Java Development Tool (JDT) is very efficient for Java debugging.

Eclipse Java开发工具(JDT)对Java调试非常有效。

Personally I stopped debugging using println since I discovered this tool. If you don't know it, I think it worth a try.

我个人发现这个工具后,我停止了使用println的调试。如果你不知道,我认为值得一试。

Manu


推荐阅读
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • Whatsthedifferencebetweento_aandto_ary?to_a和to_ary有什么区别? ... [详细]
  • 本文介绍了使用哈夫曼树实现文件压缩和解压的方法。首先对数据结构课程设计中的代码进行了分析,包括使用时间调用、常量定义和统计文件中各个字符时相关的结构体。然后讨论了哈夫曼树的实现原理和算法。最后介绍了文件压缩和解压的具体步骤,包括字符统计、构建哈夫曼树、生成编码表、编码和解码过程。通过实例演示了文件压缩和解压的效果。本文的内容对于理解哈夫曼树的实现原理和应用具有一定的参考价值。 ... [详细]
  • 使用eclipse创建一个Java项目的步骤
    本文介绍了使用eclipse创建一个Java项目的步骤,包括启动eclipse、选择New Project命令、在对话框中输入项目名称等。同时还介绍了Java Settings对话框中的一些选项,以及如何修改Java程序的输出目录。 ... [详细]
  • 本文介绍了H5游戏性能优化和调试技巧,包括从问题表象出发进行优化、排除外部问题导致的卡顿、帧率设定、减少drawcall的方法、UI优化和图集渲染等八个理念。对于游戏程序员来说,解决游戏性能问题是一个关键的任务,本文提供了一些有用的参考价值。摘要长度为183字。 ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • 用户视图(查看运行状态或其他参数)系统视图(配置设备的系统参数)system-viewEntersystemview,returnuservi ... [详细]
  • TerraformVersionTerraformv0.9.11AffectedResource(s)Pleas ... [详细]
  • springboot dubbo框架中log4j与slf4jlog4j12日志冲突问题的解决方法
    在基于springboot开发项目中,使用dubbo的RPC框架进行业务拆分,出 ... [详细]
  • IB 物理真题解析:比潜热、理想气体的应用
    本文是对2017年IB物理试卷paper 2中一道涉及比潜热、理想气体和功率的大题进行解析。题目涉及液氧蒸发成氧气的过程,讲解了液氧和氧气分子的结构以及蒸发后分子之间的作用力变化。同时,文章也给出了解题技巧,建议根据得分点的数量来合理分配答题时间。最后,文章提供了答案解析,标注了每个得分点的位置。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • 本博文基于《Amalgamationofproteinsequence,structureandtextualinformationforimprovingprote ... [详细]
author-avatar
性感然小猫儿丿
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有