domain: add Python domain to list
[lttng-docs.git] / contents / using-lttng / instrumenting / c-application / tracelog.md
CommitLineData
b23ecad2
PP
1---
2id: tracelog
3since: 2.7
4---
5
6The `tracelog()` API is very similar to [`tracef()`](#doc-tracef). The
7only difference is that it accepts an additional log level parameter.
8
9The goal of `tracelog()` is to ease the migration from logging to
10tracing.
11
12Here's an example:
13
14~~~ c
15#include <lttng/tracelog.h>
16
17void my_function(int my_integer) {
18 /* ... */
19
20 tracelog(TRACE_INFO, "my message, my integer: %d", my_integer);
21
22 /* ... */
23}
24~~~
25
26See [LTTng-UST library reference](#doc-liblttng-ust-tracepoint-loglevel)
27for the list of available log level names.
28
29Link your application with `liblttng-ust`:
30
31<pre class="term">
32gcc -o app app.c <strong>-llttng-ust</strong>
33</pre>
34
35Execute the application as usual:
36
37<pre class="term">
38./app
39</pre>
40
41The events produced by `tracelog()` calls are prefixed with
42`lttng_ust_tracelog:`. To enable `tracelog()` events matching a range
43of log levels, do:
44
45<pre class="term">
46lttng enable-event --userspace 'lttng_ust_tracelog:*' \
47 --loglevel TRACE_INFO
48</pre>
49
50This enables all `tracelog()` events with a log level at least as important
51as `TRACE_INFO`.
52
53To enable `tracelog()` events matching a specific log level, do:
54
55<pre class="term">
56lttng enable-event --userspace 'lttng_ust_tracelog:*' \
57 --loglevel-only TRACE_WARNING
58</pre>
59
60See [Enabling and disabling events](#doc-enabling-disabling-events) for
61more options.
This page took 0.027669 seconds and 4 git commands to generate.