/// <summary> /// Logs error message in Azure table storage or Event Viewer. /// </summary> /// <param name="exception">Exception object</param> /// <param name="className">Class Name where exception occur</param> /// <param name="methodName">Name of the method.</param> /// <param name="logTableName">Name of the log table.</param> /// <param name="lineNumber">Line Number of the log table.</param> /// <returns>Error logged in event viewer</returns> public ErrorResponse MatterCenterExceptions(Exception exception, string className, string methodName, string logTableName, int lineNumber) { string errorDate = DateTime.Now.ToString(logTables.AzureRowKeyDateFormat, CultureInfo.InvariantCulture); string errorCode = string.Empty; string result = string.Empty; try { if (null != exception) { if (Convert.ToBoolean(logTables.IsLoggingOnAzure, CultureInfo.InvariantCulture)) { //// Log to Azure table storage errorDate = AzureLogger.LogInAzure(exception, className, methodName, logTableName, lineNumber, logTables, generalSettings); } else { errorResponse = new ErrorResponse() { Message = exception.Message, ClassName = className, MethodName = methodName, LineNumber = lineNumber }; //// Log to event viewer EventViewerLogger.LogInEventViewer(errorResponse.ToString(), ServiceConstants.EVENT_ERROR, logTables); } errorResponse = new ErrorResponse() { ErrorCode = exception.HResult.ToString(), ErrorDate = errorDate, Message = ServiceUtility.RemoveEscapeCharacter(exception.Message), }; } else { errorResponse = new ErrorResponse() { ErrorCode = ServiceConstants.LOGGING_FAILED_CODE.ToString(), ErrorDate = errorDate, Message = ServiceUtility.RemoveEscapeCharacter(exception.Message), Description = ServiceConstants.LOGGING_FAILED_MESSAGE }; } } catch (Exception) { errorResponse = new ErrorResponse() { ErrorCode = ServiceConstants.LOGGING_FAILED_CODE.ToString(), ErrorDate = errorDate, Message = ServiceUtility.RemoveEscapeCharacter(exception.Message), Description = ServiceConstants.LOGGING_FAILED_MESSAGE }; } return errorResponse; }