<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-baum-jmap-debug-00" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true" consensus="true">

<front>
<title abbrev="JMAP Debug">JMAP Debug Logging</title><seriesInfo value="draft-baum-jmap-debug-00" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author role="editor" initials="J.M." surname="Baum" fullname="Joris Baum"><organization>audriga</organization><address><postal><street>Alter Schlachthof 57</street>
<city>Karlsruhe </city>
<code>76137</code>
<country>Germany</country>
</postal><email>joris@audriga.com</email>
<uri>https://www.audriga.com</uri>
</address></author><author role="editor" initials="H.J." surname="Happel" fullname="Hans-Joerg"><organization>audriga</organization><address><postal><street>Alter Schlachthof 57</street>
<city>Karlsruhe </city>
<code>76137</code>
<country>Germany</country>
</postal><email>hans-joerg@audriga.com</email>
<uri>https://www.audriga.com</uri>
</address></author><date year="2023" month="April" day="6"></date>
<area>Applications</area>
<workgroup>JMAP</workgroup>
<keyword>jmap</keyword>
<keyword>debug</keyword>
<keyword>logging</keyword>

<abstract>
<t>This document specifies a data model for extending the JMAP Response with log messages, particularly helpful for debugging.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>Data exchanges between JMAP clients and server typically produces log lines from
both the client and the server. Usually, logs are either stored locally on the
instances or sent to a dedicated logging server. However, JMAP can also be used
to supply log messages along-side the usual data exchange. This also removes the
need to operate a separate logging infrastructure or have dedicated channels for
log messages.</t>
<t>This extension adds a <tt>logs</tt> property to the JMAP
method response (defined in
<eref target="https://www.rfc-editor.org/rfc/rfc8620.html#section-3.4">RFC8620 Section 3.4</eref>)
which contains the log lines of the JMAP server.</t>
<t>An example use case would be a JMAP API software running on a third party
infrastructure in which log messages from the API cannot be sent to a dedicated logging service. Access to the third party infrastructure is restrictive in the sense that only access to the JMAP API endpoint is provided.</t>

<section anchor="conventions-used-in-this-document"><name>Conventions Used In This Document</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL
NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;,
&quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when,
they appear in all capitals, as shown here.</t>
<t>The definitions of JSON keys and datatypes in the document follow
the conventions described in the core JMAP specification <xref target="RFC8620"></xref>.</t>
</section>

<section anchor="addition-to-the-capabilities-object"><name>Addition to the Capabilities Object</name>
<t>The capabilities object is returned as part of the JMAP Session object; see
<xref target="RFC8620"></xref>, Section 2. This document defines one additional capability URI.</t>

<section anchor="urn-ietf-params-jmap-debug"><name>urn:ietf:params:jmap:debug</name>
<t>Represents support for the <strong>logs</strong> property in the JMAP method response
(defined in
<eref target="https://www.rfc-editor.org/rfc/rfc8620.html#section-3.4">RFC8620 Section 3.4</eref>)
and the <strong>LogLine</strong> data type.</t>
<t>The value of this property in the JMAP Session and account's capabilities
property is an empty object.</t>
</section>
</section>
</section>

<section anchor="response-extension"><name>Response extension</name>
<t>The <strong>Response</strong> object will be extended via:</t>

<ul spacing="compact">
<li><strong>logs</strong>: <tt>LogLine[]</tt> (optional)
An array of log lines that were created while processing the request.</li>
</ul>
<t>A <strong>LogLine</strong> object has the following properties:</t>

<ul spacing="compact">
<li><strong>level</strong>: <tt>String</tt>
The log level of the log message. MUST be one of the eight levels defined in
<eref target="https://datatracker.ietf.org/doc/html/rfc5424">RFC5424</eref>: debug, info, notice,
warning, error, critical, alert or emergency.</li>
<li><strong>message</strong>: <tt>String</tt>
The log message</li>
<li><strong>timestamp</strong>: <tt>UTCDate</tt>
The date the log message was logged.</li>
<li><strong>class</strong>: <tt>String|null</tt>
The name of the class that is currently logging.</li>
<li><strong>file</strong>: <tt>String|null</tt>
The file that initiated the log line.</li>
<li><strong>line</strong>: <tt>String|null</tt>
The exact line in the file where the log function is being called.</li>
</ul>
<t>An example list of logs sent alongside a response to Core/echo would look like:</t>

<sourcecode type="json">{
  &quot;logs&quot; : [
    {
      &quot;file&quot; : &quot;Logger.php&quot;,
      &quot;level&quot; : &quot;info&quot;,
      &quot;line&quot; : 32,
      &quot;message&quot; : &quot;Array Logger has been successfully initialized&quot;,
      &quot;timestamp&quot; : &quot;2022-01-18T10:26:56+01:00&quot;
    },
    {
      &quot;file&quot; : &quot;ErrorHandler.php&quot;,
      &quot;level&quot; : &quot;warning&quot;,
      &quot;line&quot; : 52,
      &quot;message&quot; : &quot;fopen(bridge.php):
        failed to open stream: No such file or directory&quot;,
      &quot;timestamp&quot; : &quot;2022-01-18T10:26:56+01:00&quot;
    },
    ...
  ],
  &quot;methodResponses&quot; : [
    [
      &quot;Core/echo&quot;,
      ...
</sourcecode>
</section>

<section anchor="security"><name>Security Considerations</name>
<t>Log messages might contain sensitive user data as well as detailed information
about the system on which an API server has been installed. Appropriate measures
must be taken to restrict access to JMAP Debug to trusted parties only.</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>

<section anchor="jmap-capability-registration-for-debug"><name>JMAP Capability registration for &quot;debug&quot;</name>
<t>IANA is requested to register the &quot;debug&quot; JMAP Capability as follows:</t>
<t>Capability Name: urn:ietf:params:jmap:debug</t>
<t>Specification document: this document</t>
<t>Intended use: common</t>
<t>Change Controller: IETF</t>
<t>Security and privacy considerations: this document, <xref target="security"></xref>.</t>
</section>

<section anchor="jmap-datatype-registration-for-logline"><name>JMAP Datatype Registration for &quot;LogLine&quot;</name>
<t>IANA will register the &quot;LogLine&quot; Data Type as folows:</t>
<t>Type Name: &quot;LogLine&quot;</t>
<t>Can reference blobs: No</t>
<t>Can use for state change: No</t>
<t>Capability: &quot;urn:ietf:params:jmap:debug&quot;</t>
<t>Reference: this document</t>
</section>
</section>

<section anchor="acknowledgements"><name>Acknowledgements</name>
<t>Bron Gondwana, Neil Jenkins, Alexey Melnikov, Ken Murchison, Robert Stepanek and
the JMAP working group at the IETF.</t>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"/>
</references>

</back>

</rfc>
