3

I've found tons of documentation on how to enable javax.net.debug for SSL, TLS and similar, but even in the reference documentation I've not found how to totally disable it overriding programmatically a previous setting.

My exact problem is that in a Tomcat instance another application performs the following instruction:

System.setProperty("javax.net.debug","all");

and this causes the catalina.out file to rise his dimension quickly and unwanted.

I've already tried to overwrite it from my Java code with the same instruciton, with "none", "off" and "false" values but with no result, still logging a plenty of TLS stuff.

For example in my application I've added this instruction:

System.setProperty("javax.net.debug","none");

but still I'm getting full log.

4

3 回答 3

3

问题是tomcat应用程序正在覆盖你从命令行给出的任何值,如果没有办法控制这段代码在做什么,你就不能真正从命令行参数覆盖它。虽然安全管理器能够阻止设置属性,但它只能通过抛出异常来做到这一点,这可能会导致比它解决的问题更多的问题。

在这种情况下,您唯一的选择是在其他代码设置值之后,自己从代码中设置值。

如果是,则需要在 Debug 类的静态静态初始化程序运行之前javax.net.debug将选项设置为其最终值,也就是在第一条消息出现之前。这可以通过任何不用作某些选项的值来禁用(空字符串,或者不应该禁用它)。如果稍后设置,它将没有任何效果,事后无法将其关闭(除了做一些糟糕的反射黑客来访问该类的内部,这只能在 java 8 和更早版本中使用)sun.*

于 2018-10-22T15:52:56.767 回答
0

您可以通过从 IDE 的运行配置中删除以下内容来禁用它:

-Djavax.net.debug=全部

于 2021-07-21T09:54:57.877 回答
0

如果有一些 VM 参数启用 SSL 日志记录,请尝试删除它们,此外,您可以检查 eclipse.ini 文件以查看这些参数是否在那里声明。

于 2018-10-22T14:33:01.477 回答