Log LogEventInfo 没有写入正确的信息

Log LogEventInfo is not writing the correct information

我用测试数据创建了一个字典,我想用 LogEventInfo 记录它。但是,它在控制台上写的是我的办公桌名称,而不是正确的信息。

    public void LogDebugWithAdditionalFields(string logMessage, IDictionary<string, string> data)
    {
        LogEventInfo logInfo = new LogEventInfo();
        logInfo.Level = LogLevel.Debug;

        foreach (var dataItem in data)
        {
            logInfo.Properties.Add(dataItem.Key, dataItem.Value);
        }

        var logger = GetLoggerFullName();
        logger.Log(logInfo);
    }

    public Logger GetLoggerFullName()
    {
        return LogManager.GetLogger(GetType().FullName);
    }

感谢您的帮助。

我忘了设置正确的布局。它应该在布局中包含 ${event-properties:item=String}

here.