留言板

PortletHotDeployListener Overwriting Previously Set Logging Levels

lsli lsli,修改在12 年前。

PortletHotDeployListener Overwriting Previously Set Logging Levels

Junior Member 帖子: 62 加入日期: 08-11-11 最近的帖子
I currently set some custom logging levels in my portal-log4j-ext.xml file in my Liferay EXT plugin. I use my debugger and see that these custom logging levels are being correctly set - at least initially in the initialization sequence.

However, I have a custom portlet (Seam, ICEfaces) that loads up later in the initialization. I put a breakpoint on Log4JUtil.setLevel with a breakpoint condition to activate when the name argument equals the log category I'm interested in. I see if produces the following stack trace once that breakpoint is hit:

Log4JUtil.setLevel(String, String) line: 86	
Log4JUtil.configureLog4J(URL) line: 77	
PortletHotDeployListener.initLogger(ClassLoader) line: 448	
PortletHotDeployListener.doInvokeDeploy(HotDeployEvent) line: 235	
PortletHotDeployListener.invokeDeploy(HotDeployEvent) line: 101	
HotDeployUtil._doFireDeployEvent(HotDeployEvent) line: 109	
HotDeployUtil._fireDeployEvent(HotDeployEvent) line: 182	
HotDeployUtil.fireDeployEvent(HotDeployEvent) line: 38	


This is telling me that my portlet causes the PortletHotDeployListener to be fired off every time the app is started. And the PorletHotDeployListener initializes the logger each and every time on loading the portlet (see call to initLogger):

PortletHotDeployListener.java:
protected void initLogger(ClassLoader portletClassLoader) {
		Log4JUtil.configureLog4J(
			portletClassLoader.getResource("META-INF/portal-log4j.xml"));
	}


And if you look at the resource it is trying to get (META-INF/portal-log4j.xml), you can see the URL path as:

vfszip:<path_to_jboss>/server/default/deploy/<portlet_war_file>/WEB-INF/lib/portal-impl.jar/META-INF/portal-log4j.xml</portlet_war_file></path_to_jboss>


This is quite frustrating as this means my logging set in my custom portal-log4j-ext.xml gets overwritten with the default settings (in particular, I'm trying to set the logging level for category com.liferay.portal.util.PortalImpl to ERROR). So what can I do to fix this, other than possibly removing the call to initLogger in PortletHotDeployListener.java? And is removing the initLogger call in PortletHotDeployListener.java a good idea? Why is it even called in the first place when Log4JUtil.configureLog4J has already been called by InitUtil.java during the portal startup?

Currently using:

Liferay 6.0.6 GA
JBoss 5.0.1 GA
Seam 2.2.1 Final
ICEfaces 1.8.2