-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove backslashes from output #40
Comments
Where/what is generating that event? I'm not seeing it on my side so I'd like to have something I can write a test case against. |
This was tomcat that was writing to a file using this plugin. Notice the "/" showing up. The JSON file would then show a string such as: {"thread_name":"localhost-startStop-1","message":"Using the database properties file at : /data/program/../config/trunk.database.properties","@timestamp":"2014-09-09T19:30:52.302Z","level":"INFO","mdc":{},"file":"?","class":"?","line_number":"?","logger_name":"program.hibernateConfig.HibernatePropertyManager","method":"?","@Version":1,"source_host":"trunk-websrv-1"} |
@djtecha I just want to verify that this ONLY happens when using the json formatter and not using standard log4j formatting? There's nothing explict in this code that would do that. It COULD be a json serialization thing but forward slashes don't NEED to be escaped. I'm looking now to see if this is something Hibernate is doing. |
It seems to me that the escaping happens because of https://code.google.com/p/json-smart/source/browse/2.0/json-smart/src/main/java/net/minidev/json/JSONObject.java?r=ec861df8c01fd61f6dc6cd395a96edee99f225d3#51 (at least if you believe the comment). It'd be nice if there was a way to either log an "unescaped" string, and/or pass in a map, e.g.: log.info([key: 'val']) I think it's possible with something like the below: org.apache.log4j.spi.LoggingEvent loggingEvent =
new org.apache.log4j.spi.LoggingEvent(
'my.cat',
new org.apache.log4j.spi.RootLogger(org.apache.log4j.Level.INFO),
org.apache.log4j.Level.INFO,
[ key: "{ some: 'more' }" ],
null
)
net.minidev.json.JSONObject logstashEvent = new net.minidev.json.JSONObject()
logstashEvent.put("message", loggingEvent.getMessage());
println "logstashEvent: ${logstashEvent.toString()}" This outputs:
|
Is there a way to remove the escape chars. from showing up in the output? This leads to ugly logs, especially when links are involved that I'd like to follow.
Ex: User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0
should show up as:
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0
The text was updated successfully, but these errors were encountered: