Log4j 2.0 异常的解决方法
本节列出了 Log4j 2.0 异常的解决方法:
异常 - 打印带有文件位置信息和特殊字符的异常日志。例如问号 (?),如下所示:
org.apache.solr.client.solrj.SolrServerException: Server refused connection at: http://xxx.xxxx.com:8085/solr/wblib
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:688) ~[xxxxx.jar:?]
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:266) ~[xxxxx.jar:?]
大多数 Windchill 控制台基础实用程序在异常日志中可能具有类似的观察值。要从异常日志中隐藏 [<类位置> : <文件名>],请在运行实用程序时添加以下自变量:
windchill --javaargs=-Dlog4j2.configurationFile\=log4j.properties <name of the utilities>
例如:
windchill --javaargs=-Dlog4j2.configurationFile\=log4j.properties wt.auth.Authentication
在预设 Log4j 2.0 库中,PatternLayout 类包含特性 alwaysWriteExceptions=true,该特性可将 %xEx 转换模式附加到上述布局的末尾。%xEx 转换模式与 Log4j 1.2 中使用的 %ex 模式相同,但 %xEx 中也包含类封装信息。如果不需要日志中的位置和类封装信息,请设置特性 alwaysWriteExceptions = false 并在布局模式中显式添加 %ex,如下所示:
appender.stdout.type = Console
appender.stdout.name = stdout
appender.stdout.follow = false
appender.stdout.layout.type = PatternLayout
appender.stdout.layout.alwaysWriteExceptions = false
appender.stdout.layout.pattern = %-5p : %c %X{user} - %m%ex%n
异常 - 缺少实施异常,例如:
wt.method.server - MethodServerMain abort java.lang.AbstractMethodError: Missing implementation of resolved method abstract getLogger()Lorg/apache/logging/log4j/Logger; of interface com.infoengine.SAK.Tasklet.
at com.infoengine.SAK.BasicTasklet.postInvoke(BasicTasklet.java:1497)
at com.infoengine.compiledTasks.file.opt.ptc.kangaroo_220.Windchill.tasks.wt.federation.queryprincipals$2exml.invoke(queryprincipals$2exml.java:105)
清除 Info*Engine 缓存并移除 <WT_HOME>\tasks\codebase\com\infoengine\compiledTasks\file 下的文件。
这对您有帮助吗?