如何解析外部配置文件中的类引用以进行 grails war 部署?
我正在使用 Grails 1.3.7。我建立了一个战争文件&将其部署到tomcat中。我有一个外部 groovy 配置文件,用于设置日志记录。我在声明中添加了一些 perf4j 日志附加程序,但现在配置文件无法编译,因为它无法解析完全限定的类名。
代码如下所示:
log4j = {
...
// file appender that writes out the URLs of the Google Chart API graphs generated by the performanceGraphAppender
def performanceGraphFileAppender = new org.apache.log4j.FileAppender(
fileName: "log/perfGraphs.log",
layout: pattern(conversionPattern: '%m%n')
)
appender name: 'performanceGraphFileAppender', performanceGraphFileAppender
// this appender creates the Google Chart API graphs
def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
graphType: 'Mean', // possible options: Mean, Min, Max, StdDev, Count or TPS
tagNamesToGraph: 'tag1,tag2,tag3',
dataPointsPerGraph: 5
)
performanceGraphAppender.addAppender(performanceGraphFileAppender)
appender name: 'performanceGraph', performanceGraphAppender
...
}
写入日志的错误消息如下:
script1317679813518843914255.groovy: 38: unable to resolve class org.perf4j.log4j.GraphingStatisticsAppender
@ line 38, column 34.
def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
我正在构建的 war 文件包含所有必需的 JAR。关于如何让它解决参考文献有什么想法吗?
谢谢,
吉恩
I am using Grails 1.3.7. I build a war file & deploy it in tomcat. I have an external groovy configuration file that I use to set up logging. I added some perf4j logging appenders to the declaration, but now the configuration file fails to compile because it cannot resolve the fully-qualified class names.
The code looks like this:
log4j = {
...
// file appender that writes out the URLs of the Google Chart API graphs generated by the performanceGraphAppender
def performanceGraphFileAppender = new org.apache.log4j.FileAppender(
fileName: "log/perfGraphs.log",
layout: pattern(conversionPattern: '%m%n')
)
appender name: 'performanceGraphFileAppender', performanceGraphFileAppender
// this appender creates the Google Chart API graphs
def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
graphType: 'Mean', // possible options: Mean, Min, Max, StdDev, Count or TPS
tagNamesToGraph: 'tag1,tag2,tag3',
dataPointsPerGraph: 5
)
performanceGraphAppender.addAppender(performanceGraphFileAppender)
appender name: 'performanceGraph', performanceGraphAppender
...
}
and the error message that's written out into the log is this:
script1317679813518843914255.groovy: 38: unable to resolve class org.perf4j.log4j.GraphingStatisticsAppender
@ line 38, column 34.
def performanceGraphAppender = new org.perf4j.log4j.GraphingStatisticsAppender(
The war file I am building contains all the required JARs. Any thoughts on how to get it to resolve the references?
Thanks,
Gene
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
部署后有可能开始使用 tomcat 中的 log4j。看一下
lib
文件夹,也许它包含 log4j jar。如果这是真的 - 它使用不同的类加载器,则看不到您的 perf4j 类。您可以尝试将 perf4j jar 放入 tomcat 的
lib
中,也许可以解决此问题There is a possibility that after deployment, it starts using log4j from tomcat. Take a look at
lib
folder, maybe it's contains log4j jars. If that's true - the it uses different classloader, that can't see your perf4j classes.You can try to put your perf4j jars into tomcat's
lib
, probably it can fix this issue