Bojan Veljanovski's Tech Blog

What to Log

Logging

You could log:

What Properties to Log?

Use the following log properties where applicable:

Property Description
Timestamp the log event's timestamp
Level the log level, e.g. info, debug, warning, error, fatal
SourceContext the full name of the class from where the log was added (the logger name of the log entry)
Message the log event's message
Exception the full exception message and stack trace (if there is any)
RequestMethod the HTTP request method (e.g. POST, GET, PUT, DELETE)
RequestPath the HTTP request path
StatusCode the HTTP response status code
ClientIP the request caller's IP address
CorrelationId the ID for request or operation tracking across multiple services
MachineName the name of the machine on which the service is running
Version the version of the app
UserAgent the HTTP user agent
UserId the authenticated user's ID making the request

What NOT to Log?

Always consider the security and privacy implications of the information you log, especially in production environments. Implementing proper log management and reviewing your logging practices regularly can help ensure that your logs serve their intended purpose without compromising sensitive data.

Here's a list of things you should generally avoid logging: