I have generated some proxy classes that are consumed by a Java Service. (using WSDL2JAVA)
I need to find a way to log requests and responses whenever the proxy class invokes the respective external web service.
Is there any easy way to achieve this?
Thanks!
Silvio.
If you are using Axis, configure log4j like this:
log4j.rootLogger=ERROR
log4j.appender.axisLogFile=org.apache.log4j.RollingFileAppender
log4j.appender.axisLogFile.File=soap-messages.log
log4j.appender.axisLogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.axisLogFile.layout.ConversionPattern=[%d{DATE} - %-5p] %m%n
log4j.logger.org.apache.axis.transport.http.HTTPSender=DEBUG, axisLogFile
This is awesome, you need add the following for in java code.
PropertyConfigurator.configure(<log4j property file>);
Related
Is it possible to create a user-defined level of log in java? If yes can someone give me an example?
I have an web application, and some web services exposed by the same. I want to create a new log file for every new request. Is there any way I can do it? If yes, please share the solution. Thank you in Advance :)
You can use something like MDC(Mapped Diagnostic Context) in LOGBack.
For WEB application javax.servlet.Filter can be used to set context values for every request.
example: http://logback.qos.ch/xref/chapters/mdc/UserServletFilter.html
Is it possible to transfer the AEM (v5.6) logs to the Log4j server? Or there is some best practice for centralized AEM logging?
I haven't dealt much with AEM. It seems the Apache Sling Logging services configure only the FileAppender.
For CQ5.5 there is no log4j.xml. All the CRX logger needs to
configured using sling config.
We can use Apache Sling Logging Logger
Configuration
(https://docs.adobe.com/docs/en/aem/6-0/deploy/configuring/monitoring-and-maintaining.html#Create%20a%20Custom%20Log%20File)
or LogBack
(http://sling.apache.org/documentation/development/logging.html#logback-integration)
AEM provides the loggers out of the box as you have seen. Typically if you want centrallized log handling I would suggest mounting a super-high-speed shared volume and having all instances log there, just for performance/speed reasons.
You might want to check out this:
http://adobe-consulting-services.github.io/acs-aem-commons/features/syslog-appender.html
It is AEM6 only, but you could look at the code and do it that way.
This uses logback, not log4j, but it should solve your problem.
The other option, really, is to write your own logging service and use that and configure the appender in the code. I do not see the normal XML files anywhere. I'm curious if you come across them.
Let me know if I can help further.
I have embedded Jetty container inside my main server and I also use Jersey 2.5 for handling REST resources.
everything seems to work well and now I would like to pass my server's context class into each of my REST resources.
I'm having hard time understanding how to do that...
If someone can provide full code example - it could be awesome!
Many thanks
What exactly do you mean when you say you have a Jetty container inside your "main server"? Are you programmatically executing Jetty within the application? Also, when you say "context" are you referring to the ServletContext?
I try to enable NCSA request logging in pax-web 1.1.4. The recommended way to do it doesn't work. The file was created but it stays empty. Looking in source code I found that pax web implementation of Jetty server passes requests to JettyServerHandlerCollection which assumes that every handler should correspond a context. So it looks impossible for me just to use org.ops4j.pax.web.log.ncsa.* options.
Am I missing something or this functionality doesn't work in pax web? Are there any workarounds?
Yep, it's a bug in Pax-Web and has been filed on PAXWEB-416
I think there are several ways to hide wsdl's from end users for WebSphere (6.1). We use axis to publish Web Services and I currently updated the custom Servlet class (which extends AxisServlet) and override the service method to throw 404 error for urls like: http://xxxx/services/MyService?wsdl. The other option may be adding filters.
Are there any other alternative ways?
Thanks.
What lutz pointed to is correct. You should add some authentication mechanism to your SOAP interfaces if they can do something potentially harmful. However if you insist you can block the access to anything that looks like wsdl query, for instance with
Servlet Filter for your applications
Front-end web server configuration that will redirect those queries to somewhere else, ie.
RewriteEngine On
RewriteRule ^(.+)?wsdl$ /error.html