After going threw the XML I realized that the stored procedure ressposible for adding the category was not set right.I had it set to ServerLogger an the actual stored procedure name was AddCateogry.
Logging data to database with EnterpriseLibrary
-
28-06-2022 - |
문제
Hi I am trying to integrate EnterprisLibrary Logging block into my application using a database as storage.Here is what I have so far:
I have runed the scripts for the database and have created a database called e-shop.Logging that has 3 tables Category , CategoryLog and Log.
I have created this configuration on my web config:
In my code I have this configuration class:
public static class LoggerBootstrapper
{
public static void Start()
{
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
Logger.SetLogWriter(new LogWriterFactory().Create());
}
}
This is called in Global.asax in my WebApi project.
And this is the class that I use in my entire application:
[InjectorRegistration(typeof(IExceptionLogger))]
public class ExceptionLogger : IExceptionLogger
{
public void LogServerException(Exception exception)
{
string logger = LoggerCategories.ServerLogger.ToString();
Logger.Write(exception, LoggerCategories.ServerLogger.ToString());
}
public void LogClientException(Exception exception)
{
Logger.Write(exception, LoggerCategories.ClientLogger.ToString());
}
}
public enum LoggerCategories
{
ServerLogger,
ClientLogger
}
When I call the LogServerException or LogClientException , the data get's stored in the Log table but nothing get's stored in the Category and CategoryLog tables.
I first asummed that I had to add the categories myself so I added this two categories: ServerLogger ClientLogger
Of course it did not work.I have seen this configured that when you add a category it automaticly get's added to the Category table and when an exception get's added the mapping beetween Category and Log is automaticly done threw CategoryLog.
Does anyone know what I am doing wrong here? Why when I am adding an exception data get's added only in the log table and the other two table are not updated?
해결책