Open JennyAndersen opened 8 months ago
Implement Serilog logging using the _logger.Information method consistently across the entire project.
Apply logging in the following projects:
EXAMPLE: public class AnimalRepository : IAnimalRepository { private readonly AnimalDbContext _context; private readonly ILogger _logger;
public AnimalRepository(AnimalDbContext context) { _context = context; _logger = Log.ForContext<AnimalRepository>(); } public async Task<Animal> GetByIdAsync(Guid Animalid) { try { _logger.Information($"Getting animal by ID {Animalid}..."); var animal = await _context.Animals.FindAsync(Animalid) ?? throw new ArgumentNullException(nameof(Animal), "Cannot find null animal."); _logger.Information($"Animal with ID {animal.AnimalId} found."); return animal!; } catch (Exception ex) { _logger.Error(ex, $"An error occurred while getting animal by ID {Animalid}."); throw; } }
Implement Serilog logging using the _logger.Information method consistently across the entire project.
Apply logging in the following projects:
EXAMPLE: public class AnimalRepository : IAnimalRepository { private readonly AnimalDbContext _context; private readonly ILogger _logger;