确定 Java 应用程序是否在 Eclipse 中处于调试模式 [英] Determine if a java application is in debug mode in Eclipse

查看:38
本文介绍了确定 Java 应用程序是否在 Eclipse 中处于调试模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据是否正在调试来更改日志记录级别,但是我找不到代码片段来检查应用程序是否在调试模式下运行.

I want to change the logging level depending if I'm debbugging or not, but I can't find a code snippet to check if the application is running in debug mode.

我正在使用 Eclipse 来调试应用程序,所以如果该解决方案仅适用于 Eclipse,那就没问题了.

I'm using eclipse to debug the application, so if the solution only works within Eclipse it will be fine.

推荐答案

您可以修改调试配置.例如,仅在调试配置中添加特殊的 VM 参数.您可以使用 System.getProperties() 读取提供的参数.

You could modify the Debug Configuration. For example add a special VM argument only in the Debug Configuration. You can use System.getProperties() to read the supplied arguments.

更好的是,修改配置(运行和调试)以加载不同的日志配置文件.如果您需要编写代码来确定日志记录级别,那就不好了.这应该只是配置问题.

Even better, modify the configurations (Run and Debug) to load a different logging configuration file. It isn't good if you need to write code to determine the logging level. This should only be a matter of configuration.

这篇关于确定 Java 应用程序是否在 Eclipse 中处于调试模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆