Could anyone tell me if thats correct config for saving logs to database and i got errors in my custom layouts or smth else?
With that config i got exception on creating Logger with innerexception msg: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
With some standard config(to file) i dont get that exception
Edit: db script for table:
CREATE TABLE [dbo].[NLog_Error](
[Id] [int] IDENTITY(1,1) NOT NULL,
[time_stamp] [datetime] NOT NULL,
[host] [nvarchar](max) NOT NULL,
[type] [nvarchar](50) NOT NULL,
[source] [nvarchar](50) NOT NULL,
[message] [nvarchar](max) NOT NULL,
[level] [nvarchar](50) NOT NULL,
[logger] [nvarchar](50) NOT NULL,
[stacktrace] [nvarchar](max) NOT NULL,
[allxml] [ntext] NOT NULL,
CONSTRAINT [PK_NLogError] PRIMARY KEY CLUSTERED
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
ALTER TABLE [dbo].[NLog_Error] ADD CONSTRAINT [DF_NLogError_time_stamp] DEFAULT (getdate()) FOR [time_stamp]
OK i solved my problem by setting:
<nlog autoReload="true" throwExceptions="true" internalLogFile="c:\nlog.txt" internalLogLevel="Info"
internalLogToConsole="true"> so i could get error log where i found that my connection stirng was wrong(it got ' " ' mark at start what is really bad)
I'd suggest using the connectionStringName attribute and pointing to a named connectionString in your web.config/app.config file. Better for maintenance and only one place to make this kind of mistake.