Having a web.config connection for log4net and works fine ( without tcp/ port etc )
Now Using connection details from Windows Azure SQL Database (formerly SQL Azure) Connection String
web.config 例如:数据源= tcp:axxxxxx03,1433;初始目录= cxxuserdb;用户id = cxxuserid; password; password = cxxuserpassword; persist Security security info = false;
When I running the application getting the below error ( captured using Diagnostics property )
ERROR [AdoNetAppender] ErrorCode: GenericFailure. Exception while writing to database
System.Data.SqlClient.SqlException (0x80131904): The INSERT permission was denied on the object 'MyTable'
MyTable having identity and index also defined
Question , What are the changes we have to do when we use Azure Connection String instead of our old connection in web.config. ?
请为数据库用户提供插入该数据库的权限。使用SQL Server Management Studio在用户数据库上运行以下语句。
-- Run this on the user database not on master database
EXEC sp_addrolemember 'db_datawriter', 'CXXUserID'
您也可以在数据库上分配读取权限。
EXEC sp_addrolemember 'db_datareader', 'CXXUserID'
Created a table with clustered index and given permission
EXEC sp_addrolemember 'db_datawriter', 'CXXUserID'
EXEC sp_addrolemember 'db_datareader', 'CXXUserID'
CREATE TABLE [dbo].[Log4Net]
(
[Id] [int] IDENTITY (1, 1) NOT NULL,
[Date] [datetime] NOT NULL,
[Thread] [varchar] (255) NOT NULL,
[Level] [varchar] (50) NOT NULL,
[Logger] [varchar] (255) NOT NULL,
[Message] [varchar] (4000) NOT NULL,
[Exception] [varchar] (2000) NULL,
CONSTRAINT [PK_MyLog] PRIMARY KEY CLUSTERED ([Id] ASC)
)
few more information available : https://blog.tallan.com/2017/07/18/log-management-with-log4net-and-microsoft-azure/