[
https://issues.apache.org/jira/browse/LOG4J2-623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13995487#comment-13995487
]
Gary Gregory commented on LOG4J2-623:
-------------------------------------
As a reminder, the goal is to be able to ship a single XML Schema and a single
JSON Schema to describe an Event.
Here we are only talking about the context map portion of the schema.
For XML, the representation of a context map should be along the line of:
Example 1:
{code:xml}
<ContextMap>
<item key="MDC.B" value="B_Value"/>
<item key="MDC.A" value="A_Value"/>
</ContextMap>
{code}
Example 2:
{code:xml}
<ContextMap>
<item key="MDC.C" value="C_Value"/>
<item key="MDC.D" value="D_Value"/>
</ContextMap>
{code}
Both of the above XML documents and all other documents for any key and value
can be validated with the _same_ XML Schema, for example:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="item">
<xs:complexType>
<xs:attribute name="value" use="required"/>
<xs:attribute name="key" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="ContextMap">
<xs:complexType>
<xs:sequence>
<xs:element ref="item" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
{code}
While the following two documents cannot be validate with the same XML schema.
Using XML Schema's "any" is not a solution because that would allow anything at
all.
{code:xml}
<ContextMap>
<MDC.B>B_Value</MDC.B>
<MDC.A>A_Value</MDC.A>
</ContextMap>
{code}
and:
{code:xml}
<ContextMap>
<MDC.C>C_Value</MDC.C>
<MDC.D>D_Value</MDC.D>
</ContextMap>
{code}
For JSON, there is no W3C standard for JSON itself or any JSON Schema, but I do
see references to http://json-schema.org/
Are you saying that you can write a JSON Schema that can validate both of the
following documents while allowing for any key and value?
{code:javascript}
"mapName: {
"MDC.B": "B.Value",
"MDC.A": "A.Value"
}
{code}
and
{code:javascript}
"mapName: {
"MDC.C": "C.Value",
"MDC.D": "D.Value"
}
{code}
I'd like to see if so we can ship it!
> Better structure of Thread Context Map in JSONLayout
> ----------------------------------------------------
>
> Key: LOG4J2-623
> URL: https://issues.apache.org/jira/browse/LOG4J2-623
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Affects Versions: 2.0-rc1
> Reporter: Mikael Ståldal
> Assignee: Ralph Goers
> Priority: Minor
> Fix For: 2.0-rc2
>
>
> Currently, the Thread Context Map looks like this in JSONLayout:
> {code:JavaScript|title=Current}
> "Properties":[
> {
> "name":"UserName",
> "value":"admin"
> },
> {
> "name":"OrgName",
> "value":"test"
> }
> ]
> {code}
> This does not properly make use of the JSON data format. Since the Thread
> Context Map is a map, it should be represented as a JSON object. And why not
> name it "mdc" rather than the quite vauge "Properties"?
> {code:JavaScript|title=Suggested}
> "mdc": {
> "UserName":"admin",
> "OrgName":"test"
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]