追踪文件句柄
我有一个使用 log4j 的大耳朵,并且有一个用于设置它的配置文件。 在此配置文件中没有提及某些日志文件,但是除了配置文件中指定的文件之外,还会在日志文件夹中生成其他文件。 我搜索了 (logger|log4j|log).(properties|xml) 的其他组合,但在 Ear 中包含的所有 jar 文件中没有找到任何有希望的内容。 如何找出创建这些额外文件的违规线程/类?
I have a huge ear that uses log4j and there is a single config file that is used to set it up. In this config file there is no mention of certain log files but, additional files apart from those specified in the config file get generated in the logs folder. I've searched for other combinations of (logger|log4j|log).(properties|xml) and haven't found anything promising in all of the jar files included in the ear. How do I track down which is the offending thread/class that is creating these extra files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SysInternals 可能对 Java 类 IO 没有帮助。 尝试在写入这些日志时获取 JVM 的线程转储(例如,kill -3)。 您应该能够在堆栈跟踪顶部附近捕获带有 java.io 包的线程。
SysInternals may not help with Java class IO. Try getting a thread dump of the JVM (e.g., kill -3) while these logs are being written to. You should be able to catch a thread red handed with java.io packages near the top of the stack trace.
尝试在 File 类的构造函数以及 mkdir 和 createNewFile 方法中放置一个断点。 通常,代码将使用 File 类来创建其文件或目录。 您的 JVM 中应该包含这些类的 Java 源代码。
Try placing a breakpoint in the File class' constructors and the mkdir and createNewFile methods. Generally, code will use the File class to create its files or directories. You should have the Java source code for these classes included with your JVM.
将
-Dlog4j.debug
添加到命令行,标准输出中将会有关于如何配置的额外信息。Add
-Dlog4j.debug
to the command line and there will be extra info in standard output about how it is configured.以前是 SysInternal,现在是 Microsoft Process Explorer
http://technet.microsoft.com/en-us/sysinternals/bb896653。 aspx
“查找”菜单项 -> “查找句柄或 DLL...”
Formally SysInternal's, now Microsoft's Process Explorer
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
"Find" menu item -> "Find Handle or DLL..."