I am using asp.net mvc applicaiton and I am new about cross cutting concers. So I need to know where can I use my logger code following example.
I have an interface that logs erros. I am implementing this interface on my code.
public interface ILogger { void Log(Exception exception); }
So I have Controller, ProductService, ProductRepository classes.
public interface ProductController: ApiController{
public IHttpActionResult Get(){
try {
productService.GetProducts();
}catch(Exception e){
logger.Log(e); // 1-Should I use logging in here?
}
}
}
Product service;
public class ProductService{
public IEnumerable<Product> GetProducts(){
try {
productRepository.GetAll();
}catch(Exception e){
logger.Log(e); // 2-Should I use logging in here?
}
}
}
In repository.
public class ProductRepository{
public IEnumerable<Product> GetAll(){
try {
}catch(Exception e){
logger.Log(e); // 3-Should I use logging in here?
}
}
}
I could not determine where can I use logging code. Or add logging in everywhere.
Aucun commentaire:
Enregistrer un commentaire