首页 \ 问答 \ 如何使用Log4j记录Apache CXF Soap Request和Soap Response(How to log Apache CXF Soap Request and Soap Response using Log4j?)

如何使用Log4j记录Apache CXF Soap Request和Soap Response(How to log Apache CXF Soap Request and Soap Response using Log4j?)

我正在使用Apache CXF框架。 在我的客户端程序中,我需要记录CXF SOAP请求和SOAP响应。 当我使用

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(host);
factory.setServiceClass(MyService.class);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());

我在控制台中获得了这些SOAP请求和SOAP响应:

Nov 9, 2011 6:48:01 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns4:MYResponse
--------------------------------------

但我的实际需求是,而不是将它们打印到服务器控制台,我需要将它们放在日志文件中。

当我如图所示直接使用log4j时

log4j(factory.getInInterceptors().add(new LoggingInInterceptor()));
log4j(factory.getOutInterceptors().add(new LoggingOutInterceptor()));

它只在日志文件中打印truetrue

任何人都可以让我知道如何配置这个?


I am using the Apache CXF Framework. Inside my client program, I need to log CXF SOAP Requests and SOAP Responses. When I used

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(host);
factory.setServiceClass(MyService.class);
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());

I got these SOAP Request and SOAP Responses in the console:

Nov 9, 2011 6:48:01 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns4:MYResponse
--------------------------------------

But my actual requirement is, instead of printing them to the server console, I need to have them inside the log file.

When I used log4j directly as shown

log4j(factory.getInInterceptors().add(new LoggingInInterceptor()));
log4j(factory.getOutInterceptors().add(new LoggingOutInterceptor()));

It is only printing true and true inside the log file.

Could anybody please let me know how to configure this?


原文:https://stackoverflow.com/questions/8065737
更新时间:2023-09-04 15:09

最满意答案

val map = sc.textFile("/test.txt").map(line => {
val arr = line.split(",")
(arr(0), arr(2).toInt)
}).distinct
var mapBC = sc.broadcast(map.take(10).toMap)

其他回答

共享变量 通常情况下,当向spark操作(如map,reduce)传递一个函数时,它会在一个远程集群节点上执行,它会使用函数中所有变量的副本。这些变量被复制到所有的机器上,远程机器上并没有被更新的变量会向驱动程序回传。在任务之间使用通用的,支持...

相关问答

更多
  • val map = sc.textFile("/test.txt").map(line => { val arr = line.split(",") (arr(0), arr(2).toInt) }).distinct var mapBC = sc.broadcast(map.take(10).toMap)
  • 看变量长度。如果是cpu一次能完成读写的,不要加。比如int,short,char不要加 一次性完不成的,比如一个字符串,要加。 其他模式代替:这是最基本的线程间同步了……windows下用Event即可。创建一个Event,然后状态是未触发,之后一个线程在上面
  • 在spark中,你可以用同样的方法播放任何可序列化的对象。 这是最好的方式,因为您只向工作人员传送数据一次,然后可以在任何任务中使用它。 斯卡拉: val br = ssc.sparkContext.broadcast(Map(1 -> 2)) Java的: Broadcast> br = ssc.sparkContext().broadcast(new HashMap<>()); In spark you can broadcast any serial ...
  • 从Spark文档 广播变量是通过调用SparkContext.broadcast(v)从变量v创建的。 广播变量是v的一个包装,它的值可以通过调用value方法来访问。 下面的代码显示了这一点: scala> val broadcastVar = sc.broadcast(Array(1, 2, 3)) broadcastVar: org.apache.spark.broadcast.Broadcast[Array[Int]] = Broadcast(0) scala> broadcastVar.val ...
  • 标签和特征向量只包含双精度。 您的标签列包含一个字符串。 查看你的堆栈跟踪: Column label must be of type DoubleType but was actually StringType. 您可以使用StringIndexer或CountVectorizer进行适当的转换。 有关更多详细信息,请参阅http://spark.apache.org/docs/latest/ml-features.html#stringindexer 。 Labels and Feature Vect ...
  • sc.broadcast的返回变量是Broadcast而不是String[] 。 如果要访问该值,只需在变量上调用value()即可。 从你的例子来看,它将是: Broadcast broadcastedFieldNames = sc.broadcast(fieldNames) DataFrame df = sourceFrame.toDF(broadcastedFieldNames.value()) 请注意,如果您使用Java编写此函数,则可能需要将SparkCo ...
  • broadcast用于将对象传送给每个工作节点。 该对象将在该节点上的所有分区之间共享(并且对于集群中的每个节点,值/ ie对象是相同的)。 广播的目标是在工作节点上的许多不同任务/分区中使用相同数据时节省网络成本。 相比之下, mapPartitions是RDD上可用的一种方法,其工作原理与map一样,仅适用于分区。 是的,您可以定义新的对象,例如jdbc连接,然后每个分区都是唯一的。 但是,您不能在不同的分区之间共享它,并且在不同的节点之间分配更少。 broadcast is used to ship ...
  • Spark使用Akka Actor进行RPC和消息传递,而后者使用Netty。 另外,为了移动批量数据,使用Netty。 对于混洗数据,可以选择使用Netty。 默认情况下,NIO直接用于传输洗牌数据。 对于广播数据(驾驶员对所有员工的数据传输),默认情况下使用Jetty。 Spark uses Akka Actor for RPC and messaging, which in turn uses Netty. Also, for moving bulk data, Netty is used. For ...
  • 您的解决方案应该正常。 在这两种情况下,传递给map{Partitions}的函数将在序列化时包含对广播变量本身的引用,但不包含对其值的引用,并且仅在节点上计算时调用bcast.value 。 需要避免的是类似的东西 def mapper(bcast: Broadcast): SomeRow => Int = { val value = bcast.value row => value(row._1) } Your solution should work fine. In both cases ...
  • 我认为使用Scala处理Cassandra数据的最佳工具是spark-cassandra-connector 。 它非常简单而强大。 I think the best tool to work on Cassandra data with Scala would be spark-cassandra-connector . It is so easy and powerful.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)