2

我在 Tomcat6 上有一个 Liferay 设置。我最初通过在类文件夹中添加 log4j.properties 文件和在 web-inf/lib 中添加 log4j.jar 文件来将 Log4j 用于 portlets/webapps。

现在我们在 tomcat/lib 文件夹中有几个可用的石英作业,我也想为这些作业启用 log4j 日志记录。

对于这些石英作业,我在 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 ...

如何消除此错误?

有什么方法可以保留一个 log4j.properties 文件,它可以被 shared/lib 和 portlet/webapps 使用。

4

2 回答 2

1

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

private static Logger logger = Logger.getLogger(FooBar.class.getName());

and not to have log4j.properties under any lib or class folder but having it under a folder named resources.

AFAIK this should be a place where the both parts of your application may have access to.

于 2011-06-02T10:25:00.887 回答
1

Liferay 中的已知问题:http: //issues.liferay.com/browse/LPS-9376

就我而言,问题是在我开始使用 ServiceBuilder 服务并将 Log4J Logger 添加到我的 ...LocalServiceImpl 类之一时发生的。一旦我从那里删除 Log4J 日志记录,一切都会恢复正常 - 异常消失了。

(我让服务方法抛出异常,并在与 ServiceBuilder 读取/生成的类无关的代码中捕获它们,但也可以通过将 Log4J 记录器调用更改为 Liferay 的 LogUtil 调用来完成)。

于 2011-06-11T14:09:31.703 回答