留言板
log4javascript for Liferay/JSF
Hi,
I am trying to integrate Javascript logging for my application and found the log4javascript (http://log4javascript.org).
From the quickstart page (http://log4javascript.org/docs/quickstart.html), it says
var ajaxAppender = new log4javascript.AjaxAppender(URL);
log.addAppender(ajaxAppender);
where URL is some code that will handle the Javascript Log.
I have seen codes using JSP, Servlets and JSON but interested with how it will be done with JSF.
Anybody has tried this with Liferay/JSF? You assistance is highly appreciated.
Thanks.
I am trying to integrate Javascript logging for my application and found the log4javascript (http://log4javascript.org).
From the quickstart page (http://log4javascript.org/docs/quickstart.html), it says
var ajaxAppender = new log4javascript.AjaxAppender(URL);
log.addAppender(ajaxAppender);
where URL is some code that will handle the Javascript Log.
I have seen codes using JSP, Servlets and JSON but interested with how it will be done with JSF.
Anybody has tried this with Liferay/JSF? You assistance is highly appreciated.
Thanks.
Neil Griffin,修改在11 年前。
RE: log4javascript for Liferay/JSF
Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Are you wanting to send JavaScript log messages to a URL on the server?
Yes, Neil.
I want to send a JavaScript Log messages to a URL on the server.
This URL will be the one to handle the messages and write/append these to a log file.
The JavaScript is on the same server as the URL.
Thanks.
I want to send a JavaScript Log messages to a URL on the server.
This URL will be the one to handle the messages and write/append these to a log file.
The JavaScript is on the same server as the URL.
Thanks.
Neil Griffin,修改在11 年前。
RE: log4javascript for Liferay/JSF
Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Here is how I would recommend doing this for a JSF portlet.
In your main Facelet view (XHTML), do the following:
That will setup the javascript logging framework to log messages back to a URL that your JSF portlet can handle.
In order to handle the portlet ResourceRequest that will occur when the JavaScript engine of the browser invokes the URL...
Then in your WEB-INF/portlet.xml descriptor you would have to specify:
<portlet-class>com.foo.bar.LoggerPortlet</portlet-class>
Now, there is another way of handling this that is more "JSF"ish, which would be to create a Resource and ResourceHandler. But the serveResource way might be good enough for your requirements.
In your main Facelet view (XHTML), do the following:
<portlet:resourceurl var="loggerResourceURL">
<portlet:param name="log4javascript" value="true" />
</portlet:resourceurl>
<script>
var ajaxAppender = new log4javascript.AjaxAppender(#{loggerResourceURL});
log.addAppender(ajaxAppender);
</script>
That will setup the javascript logging framework to log messages back to a URL that your JSF portlet can handle.
In order to handle the portlet ResourceRequest that will occur when the JavaScript engine of the browser invokes the URL...
package com.foo.bar;
public class LoggerPortlet extends GenericFacesPortlet {
@Override
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws PortletException,
IOException {
String log4javascript = resourceRequest.getParameter("log4javascript");
if (Boolean.TRUE.equals(log4javascript)) {
// handle logging
}
else {
super.serveResource(resourceRequest, resourceResponse);
}
}
}
Then in your WEB-INF/portlet.xml descriptor you would have to specify:
<portlet-class>com.foo.bar.LoggerPortlet</portlet-class>
Now, there is another way of handling this that is more "JSF"ish, which would be to create a Resource and ResourceHandler. But the serveResource way might be good enough for your requirements.