getting more info in HTMLLayout of log4j - html

I have been using log4j 's HTMLLayout for getting logs in html format.However,it only allows 5 columns.I would like to get the name of method where the logging request was issued.Is there any way to do this?(I know it is possible in PatternLayout using Conversion character M.But I don't think that option exists for HTMLLayout.
Any help appreciated
mark.

There is no way doing this for HTMLLayout. But you could write a CustomHTMLLayout that extends HTMLLayout so that you can get log in your specified HTML format.

Related

Know intended RestController in Spring implementation of ResponseBodyAdvice

The Spring ResponseBodyAdvice allows for handling the JSON-Response. I want to write it to the logger but by this would also like to add the name of the RestController being invoked in this transaction.
Can anyone tell, whether the classname is somewhere available in the parameters of the instance of ResponseBodyAdvice.
Got it. The parameter "MethodParameter" supplied to the "beforeBodyWrite"-method contains the attribute "containingClass" which provides the name of the intended Controller (I found this with testing - did not find any docs about the use of this attribute until now). That will do for me

When to encode as HTML in Grails

I often see Grails sample code where the programmer has called a method called encodeAsHTML(). I figure I should probably use this in my Grails applications (for security reasons, I assume?), but I was wondering when I should use this method. What objects/properties/etc. are candidates for the encodeAsHTML() method?
Thank you!
Use encodeAsHTML() (or encodeAsJavaScript, etc) for everything that you've got from user. For every string that could be modified by user (got from input form, from request parameter, from external API call, etc)
See also:
https://en.wikipedia.org/wiki/Cross-site_scripting
https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
I am not sure when this was introduced to Grails, but if in Config.groovy you set grails.views.default.codec="html" then encodeAsHTML() is called whenever you use ${} in GSPs.
Source: http://alwaysthecritic.typepad.com/atc/2010/06/grails-gsp-html-escaping-confusion.html

gwt, rpc service, StatusCodeException, and no logs available

sorry if my english is bad.
I have a problem while calling one of my GWT services.
On the client side, I have the following error.
[ERROR] com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
[ERROR] at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
[ERROR] at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
[ERROR] at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
...
Unhappily, I can't find any information related to this error on the server logs.
I'm in devlopment mode, and the only thing I can see in jetty is
[ERROR] 500 - POST /my/maping (127.0.0.1) 57 bytes
However, I know that my service implementation is called and that it returns a result without throwing any exception (because I use logs just before the return...) .
I have seen that this problem could be a serialization issue, but I really don't see where I miss something to make my objects serializables, ( plus, gwt compilator generally says me when something is not serializable).
And my/mapping should be finely defined, because it was working previously, and I am pretty sure that I have not modified anything related to this...
Finally, I don't find any interesting answer to my problem.
If you have any ideas, thanks in advance for your help.
ps: I use gwt 2.5.0-rc2.
This problem is mostly related to a class that forgot to implement the isSerializable or Serializable interface. Also Check if all subclassess in that class also implement isSerializable or Serializable interface.
Then verify that all class have a default no argument constructor.
If you are using JPA and the class relations are setup incorrectly, a general 500 will be thrown without an specific error messages

MOXy jaxb binding error for redefine element

Can any one help me ?
In my project, I need to pares some schema files, and need to generate xml files base on these schemas. Now ,I want to user MOXy to generate empty xml files base on these schemas dynamicly.But exception happened.
Internal Exception: com.sun.istack.SAXParseException2: "file:/F:/workspace/test/src/custom2.xsd" is not a part of this compilation. Is this a mistake for "file:/F:/workspace/test/src/custom.xsd"?
at org.eclipse.persistence.exceptions.JAXBException.errorCreatingDynamicJAXBContext(JAXBException.java:586)
at org.eclipse.persistence.jaxb.dynamic.metadata.SchemaMetadata$XJCErrorListener.error(SchemaMetadata.java:235)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:316)
at com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Internalizer.java:628)
at com.sun.tools.xjc.reader.internalizer.Internalizer.reportError(Internalizer.java:619)
at com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:262)
at com.sun.tools.xjc.reader.internalizer.Internalizer.buildTargetNodeMap(Internalizer.java:391)
at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:146)
at com.sun.tools.xjc.reader.internalizer.Internalizer.transform(Internalizer.java:108)
at com.sun.tools.xjc.reader.internalizer.DOMForest.transform(DOMForest.java:442)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:230)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:94)
at org.eclipse.persistence.jaxb.dynamic.metadata.SchemaMetadata.getJavaModelInput(SchemaMetadata.java:138)
at org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext.initializeFromMetadata(DynamicJAXBContext.java:209)
at org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory.createContextFromXSD(DynamicJAXBContextFactory.java:345)
... 2 more
I think the reason is the redefine element, because when I use import or include,it's ok. Please help me. Can't upload attachement to stackoverflow?

Using Layout with JMSAppender in Logback

I am using a JMSAppender from the Logback framework to write messages to a Websphere MQ.We have a custom Layout class and have specified it in the config file.However, the layout is not being applied. I read that the JMS appender doesn't really use a Layout class.Is there a way on how I can apply a Layout for the JMSAppender.
Suggestions are welcome.
Thanks in advance.
Although this might be a bit late and you might have figured it out already ....
i was doing some work on JMSAppender lately.
logs are sent to queues as ObjectMessage of type LoggingEventVO which is basically a serializable view of a log entry. you have everything that you need in this instance so a layout/encoder would be irrelevant. On the log consumer side you cast the message to the correct type and produce any format you like there
Take a look at LoggingEventVO src