का उपयोग कर एमएस एसक्यूएल में लॉग इन करने में असमर्थ मैं एमएसएसक्लसेवर सिंक के साथ सेरिलोग का उपयोग कर रहा हूं। भले ही मैंने Serilog.Sinks.MSSqlServer में उल्लिखित सभी चरणों का पालन किया, फिर भी मैं SQL तालिका में किसी भी संदेश को लॉग इन करने में असमर्थ हूं। मैं वास्तव में सराहना करता हूं अगर आप मुझे बता सकते हैं कि मैं किस भाग को याद करता हूं या गलत तरीके से कॉन्फ़िगर करता हूं?सेरिलोग
public ILogger Logger = null;
private ColumnOptions _columnOptions = new ColumnOptions
{
AdditionalDataColumns = new Collection<DataColumn>
{
new DataColumn() { AllowDBNull = true, ColumnName = "CreatedBy",DataType = typeof (Guid) },
new DataColumn() { AllowDBNull = true, ColumnName = "CreatedDate",DataType = typeof (DateTime)},
new DataColumn() { AllowDBNull = true, ColumnName = "StatusID",DataType = typeof (byte)},
new DataColumn() { AllowDBNull = true, ColumnName = "ModifiedBy",DataType = typeof (Guid) },
new DataColumn() { AllowDBNull = true, ColumnName = "ModifiedDate",DataType = typeof (DateTime) },
new DataColumn() { AllowDBNull = true, ColumnName = "Version",DataType = typeof (Guid) },
new DataColumn() { AllowDBNull = true, ColumnName = "SessionID", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "Username", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "IsAuthenticated", DataType = typeof(bool) },
new DataColumn() { AllowDBNull = true, ColumnName = "ClientIPAddress", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "ControllerName", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "ActionName", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "GetParameters", DataType = typeof(string) },
new DataColumn() { AllowDBNull = true, ColumnName = "Request", DataType = typeof(string) },
},
};
Logger = new LoggerConfiguration().WriteTo.MSSqlServer(
connectionString: ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(),
period: TimeSpan.Zero,
batchPostingLimit: 5,
autoCreateSqlTable: false,
tableName: "Logs",
restrictedToMinimumLevel: LogEventLevel.Verbose,
columnOptions: _columnOptions)
.CreateLogger();
यहाँ है कि मैं उपयोग कर रहा हूँ संदेश टेम्पलेट है:
यहाँ हिस्सा अपने प्रोजेक्ट से विन्यास कोड है
public const string AuditMessageTemplate = "{SessionID}, {Username}, {IsAuthenticated}, {ClientIPAddress}, {ControllerName}, {ActionName}, {GetParameters}, {Request}, {CreatedBy}, {CreatedDate}, {StatusID}, {ModifiedBy}, {ModifiedDate}, {Version}";
और यह परीक्षण के लिए मैं निम्नलिखित कोड लिखें:
for (int i = 0; i < 200; i++)
{
AuditLogger.Instance.Information(LoggerParameters.AuditMessageTemplate, auditLog.SessionID,auditLog.Username, auditLog.IsAuthenticated, auditLog.ClientIPAddress, auditLog.ControllerName,auditLog.ActionName, auditLog.GetParameters, auditLog.Request, auditLog.CreatedBy, auditLog.CreatedDate, auditLog.StatusID, auditLog.ModifiedBy, auditLog.ModifiedDate, auditLog.Version);
}
यहाँ कुछ रन-टाइम जानकारी है:
+०१२३५१६४१०६१यहाँ विधानसभाओं है कि मैं का उपयोग कर रहा है:
- Serilog 1.5.0.0
- Serilog.FullNetFx 1.5.0.0
- Serilog.Sinks.MSSqlServer 3.0.0.0
क्या आप कृपया 'सेल्फलॉग' को हुक अप कर सकते हैं और वहां से कोई आउटपुट संलग्न कर सकते हैं? निर्देश: https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics - धन्यवाद! –
आपकी टिप्पणी @NicholasBlumhardt के लिए धन्यवाद, मैंने मूल कारण ढूंढने और समस्या को हल करने में कामयाब रहा है। यह अपवाद था जो लॉग इन किया गया था: सिस्टम। ऑर्ग्यूमेंट अपवाद: ग्रिड में 4 डैश (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) के साथ 32 अंक होना चाहिए। <00000000-0000-0000-0000-000000000000 "स्टोर नहीं किया जा सकता है> बनाया गया कॉलम में। फिर से धन्यवाद। – DeveloperX
@ निकोलसब्लूमहार्ट मैं स्वयं लॉग से जुड़ा हुआ हूं और यह कुछ भी आउटपुट नहीं कर रहा है। (मुझे भी यही तकलीफ़ है)। आप जो कुछ भी चला चुके हैं? – Sinaesthetic