我有一个简单的Web服务这样的:爪哇 - 在Web服务中丰富的日志记录
@WebService
public class MyWebService
{
@WebMethod
public String ProcessQuery(@WebParam(name="query") String q)
{
// Logging here: User IP, etc.
}
public static void main(String[] args) throws Exception
{
String address = "http://127.0.0.1:8023/_WebServiceDemo";
Endpoint.publish(address, new MyWebService());
new DocumentServer();
System.out.println("Listening: " + address);
}
}
我想添加一个测井方法为我服务,以提取信息。我听说过NCSA格式和Log4J,但我不知道如何在服务中使用它们。我想记录用户的IP和其他信息。我该怎么做?
谢谢。
编辑:我应该指出,我的问题的主要部分是如何检索Web方法中的用户的IP,客户端等一些数据。
退房SLF4J的logback和日志记录。两者都非常容易。 – DwB 2011-04-11 19:30:38