English 中文(简体)
log4j with liferay and tomcat
原标题:

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.

最佳回答

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.

问题回答

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).





相关问题
MySQL like query runs extremly slow for 5000 records table

I have this issue on our production server. The application stack is, Java Web App on Tomcat 6.0.18 iBatis data access layer MySQL 5.0 database CentOS The system is deployed on virtual server having ...

Set the path of web app in META-INF/context.xml?

I m tryin to change the path of a deployed war file in Tomcat. Reading the documentation I can t figure out if this is possible without moving the context-file to the /conf directory. Is it possible ...

MySQL Connector/J Problem

So I ve been having issues with the MySQL Connector/J driver not correctly loading in a Java Web Start application that is running on Tomcat 6.0.20. I ve copied the MySQL connector JAR file into the ...

Can t connect to MySQL database from tomcat

Hey, I m getting this error: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. I m just ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

热门标签