log4j 与 liferay 和 tomcat
我在 Tomcat6 上安装了 Liferay。我最初将 Log4j 用于 portlet/webapps,方法是在类文件夹中添加 log4j.properties 文件,并在 web-inf/lib 中添加 log4j.jar 文件。
现在,我们在 tomcat/lib 文件夹中几乎没有可用的quartz作业,我也想为这些作业启用 log4j 日志记录。
对于这些quartz 作业,我已在 tomcat/lib 中复制了相同的 log4j.properties 文件。
使用新配置时,我不断收到以下错误:
Could not instantiate appender named "JOBS"
A "org.apache.log4j.RollingFileAppender" is not assignable a "org.apache.log4j.Appender" variable.
The class "org.apache.log4j.Appender" was loaded by ...
如何删除此错误?
有什么方法可以保留一个可供共享/lib 以及 portlet/webapps 使用的 log4j.properties 文件。
I have a Liferay setup on the Tomcat6. I used Log4j initially for portlets/webapps by adding log4j.properties file in the classes folder and log4j.jar file in the web-inf/lib.
Now we have few quartz jobs which are available in the tomcat/lib folder and I want to enable log4j logging for these jobs as well.
For these quartz jobs I have copied same log4j.properties file in the tomcat/lib.
With the new configuration I keep getting the following error:
Could not instantiate appender named "JOBS"
A "org.apache.log4j.RollingFileAppender" is not assignable a "org.apache.log4j.Appender" variable.
The class "org.apache.log4j.Appender" was loaded by ...
How to remove this error?
Is there any way I can keep a single log4j.properties file which can be used by both shared/lib as well as portlet/webapps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据这篇文章 问题是您已经配置了 log4j 两次。
我的解决方案是您像这样创建记录器实例
并且不要将
log4j.properties
放在任何 lib 或 class 文件夹下,而是将其放在名为resources
的文件夹下。据我所知,这应该是您的应用程序的两个部分都可以访问的地方。
According to this post the problem is that you have configured your log4j twice.
My solution would be that you create the logger instance like this
and not to have
log4j.properties
under any lib or class folder but having it under a folder namedresources
.AFAIK this should be a place where the both parts of your application may have access to.
Liferay 中的已知问题:http://issues.liferay.com/browse/LPS-9376
就我而言,当我开始使用 ServiceBuilder 服务并将 Log4J Logger 添加到我的 ...LocalServiceImpl 类之一时,问题就发生了。
一旦我从那里删除 Log4J 日志记录,一切就恢复正常 - 异常消失了。
(我让服务方法抛出异常,并在与 ServiceBuilder 读取/生成的类无关的代码中捕获它们,但也可以通过将 Log4J 记录器调用更改为 Liferay 的 LogUtil 调用来完成)。
Known issue in Liferay: http://issues.liferay.com/browse/LPS-9376
In my case, the problem occurred once I started to use ServiceBuilder services, and added Log4J Logger to one of my ...LocalServiceImpl classes.
Once I removed Log4J logging from there everything got back to norm - exception disappeared.
(I made service methods throw exceptions, and was catching them in a code not related to ServiceBuilder read/generated classes, but it could also be done by changing Log4J logger calls to Liferay's LogUtil calls).