Reputation: 745
I'm using Liferay 6.20 with a tomcat.
According to this post: Liferay: what is the default approach for logging in Liferay? I've added a logger to my basic portlet class like this:
package mypackage.katalog;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class KatalogUslugPortlet
*/
public class KatalogUslugPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(KatalogUslugPortlet.class);
@Override
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
testLogger();
super.processAction(actionRequest, actionResponse);
}
private void testLogger() {
System.out.print("SYSTEM_OUT!!!");
_log.info("INFO!!!");
_log.debug("DEBUG!!!");
_log.error("ERROR!!!");
}
}
And logs are not appearing neither in the console, nor in the tomcat logs. What could gone wrong?
Upvotes: 1
Views: 4693
Reputation: 745
The problem was not in the logger. My portlet was just drag and dropped into my site and I thought that processAction(...)
was the method that was called after each site refresh. In fact it should have look use doView(...)
method as follows:
@Override
public void doView(RenderRequest renderRequest,
RenderResponse renderResponse) throws IOException, PortletException {
testLogger();
super.doView(renderRequest, renderResponse);
}
Upvotes: 2
Reputation: 2193
The Liferay logger does not work in this way, you can login with the Liferay admin, go to Admin -> Control Panel -> Server Administration -> Log Levels - > Add Category.
There add the category mypackage.katalog
, and set the level All
.
Now, when you go to the portlet, you will see all the logs. Remember, once you restart the server, you have to do this process again!
Upvotes: 5