java - Totally disabling java net ssl debug logging
问题描述
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.
解决方案
问题是tomcat应用程序正在覆盖你从命令行给出的任何值,如果没有办法控制这段代码在做什么,你就不能真正从命令行参数覆盖它。虽然安全管理器能够阻止设置属性,但它只能通过抛出异常来做到这一点,这可能会导致比它解决的问题更多的问题。
在这种情况下,您唯一的选择是在其他代码设置值之后,自己从代码中设置值。
如果是,则需要在 Debug 类的静态静态初始化程序运行之前javax.net.debug
将选项设置为其最终值,也就是在第一条消息出现之前。这可以通过任何不用作某些选项的值来禁用(空字符串,或者不应该禁用它)。如果稍后设置,它将没有任何效果,事后无法将其关闭(除了做一些糟糕的反射黑客来访问该类的内部,这只能在 java 8 和更早版本中使用)sun.*
推荐阅读
- arrays - Vlookup 在一个单元格中的多个值
- c# - 当我构建游戏时,PlayerPrefs 不会保存或加载任何内容
- node.js - 我可以在哪里存储 db 的密码以保证其为 typeorm 配置 ormconfig.json 的安全?
- excel - 根据 2 个标准跨工作表将更改从一个单元格复制到另一个单元格
- java - 使用 spring data jpa 和 hibernate 进行审计
- tableau-api - Tableau 中的广告系列效果
- parent-child - Dax 度量来查找和显示父值和自我(自我显示为空白())
- css - 未显示 L.divIcon Leaflet 的自定义字体
- flutter - 颤振 setState 切换脚手架底部表
- python - gevent 猴子是否修补了 Queue.put 产量(上下文切换)?