Grails CXF在特定文件中写入日志

Grails CXF在特定文件中写入日志,grails,cxf,grails-2.0,Grails,Cxf,Grails 2.0,在我的应用程序中,有几个web服务是在cxf框架的帮助下实现的。我希望将每个web服务的传入请求记录在单独的文件中。e、 g requests -> ws1 interface -> incomingWs1.log requests -> ws2 interface -> incomingWs2.log 目前,我知道如何使用日志拦截器记录传入和传出的消息。这很好,但是对于intereports,我无法定义日志的输出位置。以下是使用日志拦截器的示例: @WebServic

在我的应用程序中,有几个web服务是在cxf框架的帮助下实现的。我希望将每个web服务的传入请求记录在单独的文件中。e、 g

requests -> ws1 interface -> incomingWs1.log
requests -> ws2 interface -> incomingWs2.log
目前,我知道如何使用日志拦截器记录传入和传出的消息。这很好,但是对于intereports,我无法定义日志的输出位置。以下是使用日志拦截器的示例:

@WebService(endpointInterface = "at.pdts.cxf.HelloWorld")
@InInterceptors(interceptors = "org.apache.cxf.interceptor.LoggingInInterceptor") // this works!
@Logging(limit=16000, inLocation="<stdout>", outLocation="<logger>", pretty=true) // does not work!
public class HelloWorldImpl implements HelloWorld { ...
@WebService(endpointInterface=“at.pdts.cxf.HelloWorld”)
@InInterceptors(interceptors=“org.apache.cxf.interceptor.logginInterceptor”)//这很有效!
@日志记录(limit=16000,inLocation=,outLocation=,pretty=true)//不起作用!
公共类HelloWorldImpl实现HelloWorld{。。。
经过一段时间的研究,a找到了日志注释,它提供了我搜索的位置设置,正如您在上面的代码示例中所看到的。该注释无效!我尝试了几个位置选项,如

file:///c:/log.log
file:c:\log.log
<stdout>
file:///c:/log.log
文件:c:\log.log

我希望有人能给我指出正确的方向。我在版本为2.2.1的grails应用程序中使用cxf framework 2.7.3。

解决方案非常简单。如果要使用日志注释,必须将其放在服务端点接口中。在我上面发布的示例中,注释属于HelloWorld interfa行政长官:

@Logging(limit=16000, inLocation="<stdout>", outLocation="<logger>", pretty=true)
public interface HelloWorld {
...
@日志记录(limit=16000,inLocation=“”,outLocation=“”,pretty=true)
公共接口HelloWorld{
...

使用文件URI将soap消息记录在特定文件中,例如。file:///c:/out.txt.

解决方案非常简单。如果要使用日志注释,必须将其放置在服务端点接口中。在我上面发布的示例中,注释属于HelloWorld接口:

@Logging(limit=16000, inLocation="<stdout>", outLocation="<logger>", pretty=true)
public interface HelloWorld {
...
@日志记录(limit=16000,inLocation=“”,outLocation=“”,pretty=true)
公共接口HelloWorld{
...

使用文件URI将soap消息记录在特定文件中,例如。file:///c:/out.txt.可以使用
@Logging
注释的
outLocation
属性来实现这一点,但是,提供的文件名必须是绝对文件名。下面提供了一个示例:

@Logging(limit=16000, inLocation="<stdout>", outLocation="/absolute/path/to/file", pretty=true)
public class HelloWorldImpl implements HelloWorld { ...

如果要使用名称将在运行时确定的动态文件,可以扩展
LoggingOutInterceptor
以实现此目的。

可以使用
@Logging
注释的
outLocation
属性来实现此目的,但是,提供的文件名必须是绝对文件名。下面提供了一个示例:

@Logging(limit=16000, inLocation="<stdout>", outLocation="/absolute/path/to/file", pretty=true)
public class HelloWorldImpl implements HelloWorld { ...
如果要使用名称将在运行时确定的动态文件,可以扩展
loggingOutiterCeptor
来实现这一点