62

From the terminology point of view and in general, what is the difference between a tracing and a logging ?

Thanks!

pencilCake
  • 51,323
  • 85
  • 226
  • 363
  • 3
    [Event Logging vs. Tracing](http://en.wikipedia.org/wiki/Tracing_%28software%29) sums it up nicely. – Filburt Dec 02 '14 at 08:28

4 Answers4

57

Logging is not Tracing!

Logging

When you design a big application, you need to have good and flexible error reporting - perhaps across machines - to collect log data in a centralized way. That is a perfect use case for the Logging Application Block where you configure some remote trace listener, and send the log data to a central log server which stores its log messages in a database, log file or whatever. If you use out-of-process communication, you are limited by the network performance already, which in the best case is several thousand logs/s.

Tracing

Besides Error Reporting, you also need to trace your program flow to find out where the performance bottlenecks are; even more importantly, when an error occurs, you have a chance to find out how you did get there. In an ideal world, every function would have some tracing enabled with the function duration, passed parameters, and how far you did get into your function.

Stopfan
  • 1,649
  • 15
  • 22
12

If the context is developing an Observability capability across a distributed architecture, it's common for people to talk about metrics, logs, and tracing. In this context, tracing refers to distributed tracing.

Distributed tracing is a specialised type of telemetry (similar to logging, but different), and is usually produced in a highly automated fashion through instrumentation frameworks. The telemetry is sent from the individual services in the system and aggregated by a central service (a distributed tracer), which is able to piece together telemetry from many individual services into a single trace for each request that entered the system. It can then provide a timeline and graph of how a request moved through the services in the system. The main purposes of distributed traces are to investigate performance degradations, error propagation, and dependency interactions throughout distributed systems.

Whereas tracing in a more traditional monolithic context would typically be looking at tracing individual function calls within an application, distributed tracing is typically only concerned with the interactions between services. Telemetry of function-call-level details is possible but rarely implemented.

For more info about distributed tracing, a good intro can be found at: https://opentelemetry.lightstep.com/tracing/

Graham Lea
  • 5,797
  • 3
  • 40
  • 55
6

Trace is the least filtered level of logging. Each logging statement has a level of filtering:

  • trace
  • debug
  • warning
  • error
  • severe

For example. if the logging library is configured to log with level warning then all warning, error and severe logging statements will be printing messages to the logging output.

Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148
  • 8
    I believe these terms are not quite standard based on the fact that many software vendors and/or developers use those terms in complete different ways (and contexts). Your description fits in exactly well with libraries like `log4net`, however, that doesn't necessarily apply to everything. What I believe is very common is that tracing is the process of "getting/receiving" data from an event/operation while logging is the process of outputting (sending or storing) that trace – Leo Dec 02 '14 at 08:42
  • Yes, you're correct. I'm not talking about tracing, but trace logging level. My assumption is that the question is not about tracing but about the trace level, since it's put in the same context. I've upvoted Stopfan's answer so it could be at the top. Mine is just an addendum – Boris Pavlović Dec 02 '14 at 15:23
  • So you're simply saying tracing is a subset of logging. Though one with a different paradigm in mind. Right? – mfaani Dec 13 '18 at 19:58
  • 8
    While this is true. it is also important to note the "trace level logging" != "logging traces" – Luke Hammer Sep 09 '19 at 16:18
  • 2
    Appreciate the answer but unfortunately this is misleading. Like other comments have stated, it gives the impression that tracing is just a subset of logging, or in some way analogous. The word TRACE refers to "STACK TRACE", as in: log in such great detail that you show me an entire stacktrace. – runderworld Jun 26 '21 at 20:08
  • @runderworld So yes, tracing IS a subset of logging. Logging with a lot of detail is a form of logging. – Juan Perez Dec 02 '22 at 20:11
0

Logging is for performance monitoring too. Does not need to be true that only trace is able to find out where the performance bottlenecks are. Both can work in distributed mode.

pxm
  • 1,611
  • 2
  • 18
  • 34
zsery
  • 1