xref: /curl/docs/libcurl/curl_global_trace.md (revision 1c42ea40)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_global_trace
5Section: 3
6Source: libcurl
7See-also:
8  - curl_global_init (3)
9  - libcurl (3)
10Protocol:
11  - All
12Added-in: 8.3
13---
14
15# NAME
16
17curl_global_trace - log configuration
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_global_trace(const char *config);
25~~~
26
27# DESCRIPTION
28
29This function configures the logging behavior to make some parts of curl more
30verbose or silent than others.
31
32This function may be called during the initialization phase of a program. It
33does not have to be. It can be called several times even, possibly overwriting
34settings of previous calls.
35
36Calling this function after transfers have been started is undefined. On some
37platforms/architectures it might take effect, on others not.
38
39This function is thread-safe since libcurl 8.3.0 if curl_version_info(3) has
40the CURL_VERSION_THREADSAFE feature bit set (most platforms).
41
42If this is not thread-safe, you must not call this function when any other
43thread in the program (i.e. a thread sharing the same memory) is running. This
44does not just mean no other thread that is using libcurl. Because
45curl_global_init(3) may call functions of other libraries that are similarly
46thread unsafe, it could conflict with any other thread that uses these other
47libraries.
48
49If you are initializing libcurl from a Windows DLL you should not initialize
50it from *DllMain* or a static initializer because Windows holds the loader
51lock during that time and it could cause a deadlock.
52
53The *config* string is a list of comma-separated component names. Names are
54case-insensitive and unknown names are ignored. The special name "all" applies
55to all components. Names may be prefixed with '+' or '-' to enable or disable
56detailed logging for a component.
57
58The list of component names is not part of curl's public API. Names may be
59added or disappear in future versions of libcurl. Since unknown names are
60silently ignored, outdated log configurations does not cause errors when
61upgrading libcurl. Given that, some names can be expected to be fairly stable
62and are listed below for easy reference.
63
64Note that log configuration applies only to transfers where debug logging is
65enabled. See CURLOPT_VERBOSE(3) or CURLOPT_DEBUGFUNCTION(3) on how to control
66that.
67
68# TRACE COMPONENTS
69
70## `tcp`
71
72Tracing of TCP socket handling: connect, sends, receives.
73
74## `ssl`
75
76Tracing of SSL/TLS operations, whichever SSL backend is used in your build.
77
78## `ftp`
79
80Tracing of FTP operations when this protocol is enabled in your build.
81
82## `http/2`
83
84Details about HTTP/2 handling: frames, events, I/O, etc.
85
86## `http/3`
87
88Details about HTTP/3 handling: connect, frames, events, I/O etc.
89
90## `http-proxy`
91
92Involved when transfers are tunneled through an HTTP proxy. "h1-proxy" or
93"h2-proxy" are also involved, depending on the HTTP version negotiated with
94the proxy.
95
96In order to find out all components involved in a transfer, run it with "all"
97configured. You can then see all names involved in your libcurl version in the
98trace.
99
100## `doh`
101
102Tracing of DNS-over-HTTP operations to resolve hostnames.
103
104## `read`
105
106Traces reading of upload data from the application in order to send it to the server.
107
108## `smtp`
109
110Tracing of SMTP operations when this protocol is enabled in your build.
111
112## `write`
113
114Traces writing of download data, received from the server, to the application.
115
116## `ws`
117
118Tracing of WebSocket operations when this protocol is enabled in your build.
119
120# TRACE GROUPS
121
122Besides the specific component names there are the following group names
123defined:
124
125## `all`
126
127## `network`
128
129All components involved in bare network I/O, including the SSL layer.
130
131All components that your libcurl is built with.
132
133## `protocol`
134
135All components involved in transfer protocols, such as 'ftp' and 'http/2'.
136
137## `proxy`
138
139All components involved in use of proxies.
140
141# %PROTOCOLS%
142
143# EXAMPLE
144
145~~~c
146int main(void)
147{
148  /* log details of HTTP/2 and SSL handling */
149  curl_global_trace("http/2,ssl");
150
151  /* log all details, except SSL handling */
152  curl_global_trace("all,-ssl");
153}
154~~~
155
156Below is a trace sample where "http/2" was configured. The trace output
157of an enabled component appears at the beginning in brackets.
158~~~
159* [HTTP/2] [h2sid=1] cf_send(len=96) submit https://example.com/
160...
161* [HTTP/2] [h2sid=1] FRAME[HEADERS]
162* [HTTP/2] [h2sid=1] 249 header bytes
163...
164~~~
165
166# %AVAILABILITY%
167
168# RETURN VALUE
169
170If this function returns non-zero, something went wrong and the configuration
171may not have any effects or may only been applied partially.
172