Collecting logs from B2C customers
Tags: privacy, programming, devjournal
Published: 2022-08-03 14:19:00

# We all need logs sometimes

It is no surprise, software has bugs. And what is worse, it contains bugs that are only reproducible at customer site. Regardless how good your testing is, there will always be bugs that you can't reproduce in your test labs.

What can we do in those cases? Well, we can torture customers with tons of stupid questions like "What did you do?", "what is your OS and environment?", "send me a screenshot please" and so on. But most of the time, this is just shooting into the darkness. You have idea what might be wrong, and ask, if this is the case or not. This is far from being productive, as most important bugs come from situations you would never even think of.

And this is where logging can be very helpful. If you software has ability to log every step it takes and warn about anything that is out of ordinary, this kind of log can narrow down search area significantly, and pretty fast.

# ...but everybody collects telemetry. Right?

Telemetry collection is still quite controversial topic these days. Something like 15-20 years ago it was not, meaning if you were try to collect telemetry from your customers, that would definitely end up as public scandal that would cost you at least your reputation, if not business.

Today situation is different. Social media and mobile applications made all sort of crazy stuff kinda normal. They collect so much personal data, but people tend to tolerate that in exchange for free service. Public opinion shifted significantly in this area.

And provided how much useful data you can get from collecting few metrics from your application, this made it a must have instrument for everyone who works with large numbers of customers. If you don't collect telemetry, you can be sure your competitors do. Which puts you into competitive disadvantage immediately. Therefore, everyone collects it.

Nevertheless, telemetry is not logs. It can never be so detailed. And regardless of the shift in public opinion, there are still pretty strict moral and technical boundaries of what you can and should collect. You still have to be very discreet and keep in mind customer privacy, as well as respect users internet bandwidth. Just remember, you are not Google and not Facebook. You just can't afford full blown legal battle. It will destroy you.

Therefore, no telemetry can substitute good old logs of your application, collected on the customer side.

# How do you collect logs from customers?
We at [Tonfotos](https://tonfotos.com) decided make this process as simple for customer as possible. Here's what we did:

* Customer can turn on and off logging at any time in the application Preferences.
* Even though it is trivial to turn on, we published [simple instruction](https://telegra.ph/Collecting-logs-in-Tonfotos-application-08-03) how to do that and refer to it, with pictures.
* When logging is on, log file will be located in `Downloads` folder, so user will not have hard time looking for it to send to us.
* Logging is pretty verbose, so file can become quite large pretty fast, but since it is being turned on only when necessary, that is OK.
* Additionally, we introduced some sort of 'Time machine'. That means, even before logging on, we still collect (error-only) logs of application into memory buffer. And when logging is turned on, this backlog gets flushed in the log file too. Yes, it is not that detailed, but still very useful.

What are your best practices for collecting logs from customers? Please share in comments.