| 1 | --- |
| 2 | id: saving-loading-tracing-session |
| 3 | --- |
| 4 | |
| 5 | Configuring a tracing session may be long: creating and enabling |
| 6 | channels with specific parameters, enabling kernel and user space |
| 7 | domain events with specific log levels and filters, and adding context |
| 8 | to some channels are just a few of the many possible operations using |
| 9 | the `lttng` command line tool. If you're going to use LTTng to solve real |
| 10 | world problems, chances are you're going to have to record events using |
| 11 | the same tracing session setup over and over, modifying a few variables |
| 12 | each time in your instrumented program or environment. To avoid |
| 13 | constant tracing session reconfiguration, the `lttng` tool is able to |
| 14 | save and load tracing session configurations to/from XML files. |
| 15 | |
| 16 | To save a given tracing session configuration, do: |
| 17 | |
| 18 | <pre class="term"> |
| 19 | lttng save my-session |
| 20 | </pre> |
| 21 | |
| 22 | where `my-session` is the name of the tracing session to save. Tracing |
| 23 | session configurations are saved to `~/.lttng/sessions` by default; |
| 24 | use the `--output-path` option to change this destination directory. |
| 25 | |
| 26 | All configuration parameters are saved: |
| 27 | |
| 28 | * tracing session name |
| 29 | * trace data output path |
| 30 | * channels with their state and all their parameters |
| 31 | * context information added to channels |
| 32 | * events with their state, log level and filter |
| 33 | * tracing activity (started or stopped) |
| 34 | |
| 35 | To load a tracing session, simply do: |
| 36 | |
| 37 | <pre class="term"> |
| 38 | lttng load my-session |
| 39 | </pre> |
| 40 | |
| 41 | or, if you used a custom path: |
| 42 | |
| 43 | <pre class="term"> |
| 44 | lttng load --input-path /path/to/my-session.lttng |
| 45 | </pre> |
| 46 | |
| 47 | Your saved tracing session is restored as if you just configured |
| 48 | it manually. |