In our web application, we need to log certain metadata, such as users’ IP addresses, for security and troubleshooting purposes. However, we want to ensure this doesn’t compromise users' privacy or violate regulations like GDPR. What are the best practices for securely logging such data without exposing sensitive information? Are there methods to anonymize or hash IP addresses while retaining utility for security monitoring?