/

Tags

Tags allow you to categorize and organize your logs for easier filtering and analysis. Use tags to group related logs by feature, module, or any custom criteria.

Adding Tags

Fluent API

Java
Log.withTags("performance", "database")
   .info("Database query completed");

Log.withTags("authentication")
   .warn("Failed login attempt");

Log.withTags("api", "external")
   .error("External API call failed");

Direct API

Java
import java.util.Arrays;

Log.info("User logged in", Arrays.asList("auth", "login"), null);

Common Tag Categories

Feature-Based Tags

Java
Log.withTags("authentication", "security")
   .info("Login attempt successful");

Log.withTags("payment", "transaction")
   .error("Payment gateway timeout");

Log.withTags("database", "orders")
   .warn("Slow query detected");

Component-Based Tags

Java
Log.withTags("cache", "redis")
   .info("Cache entry expired");

Log.withTags("api", "external", "payment-gateway")
   .error("External service unavailable");

Log.withTags("background-job", "email")
   .info("Email processing completed");

Tag Conventions

Java
// ✅ Good - Lowercase with hyphens
Log.withTags("user-management", "profile")
   .info("Profile updated successfully");

// ✅ Good - Simple and clear
Log.withTags("database", "performance")
   .warn("Slow query detected");

// ❌ Avoid - Inconsistent casing
Log.withTags("UserManagement", "PROFILE")
   .info("Profile updated");

Filtering and Analysis

Tags make it easy to filter and analyze logs in the ByteHide web panel:

Java
Log.withTags("payment", "gateway")
   .info("Payment processing started");
   
Log.withTags("payment", "retry")
   .warn("Payment retry attempt");
   
Log.withTags("payment", "error")
   .error("Payment processing failed");

Best Practices

Best Practices

  • Use lowercase with hyphens for consistency (e.g., "user-management")
  • Keep tags short and meaningful
  • Use multiple tags for better filtering capabilities
  • Document your tagging strategy for the team
  • Combine tags with metadata and context for comprehensive logging

Next Steps

Previous
Metadata & Context