You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NLog写入AzureBlobStorage异常:单条日志超638字符生成空文件

NLog.Extensions.AzureBlobStorage 超长日志写入异常问题

问题现象

  • 使用包版本:NLog.Extensions.AzureBlobStorage 4.2.0
  • 当日志消息长度不超过638字符时,写入Azure Blob Storage功能正常
  • 消息长度超过638字符(例如639个"a"组成的字符串)时,会生成空文件,甚至超长日志之前的消息也不会被记录
  • 将消息缩短至368字符时,功能恢复正常

复现代码

var config = new LoggingConfiguration();
var blobStorageTarget = new BlobStorageTarget
{
    Name = blobStorageTargetName,
    ConnectionString = "<my connection string>",
    Container = "myContainer",
    BlobName = $"{prefix}_YourBlobName_${{shortdate}}.log",
    Layout = "${longdate} ${level} ${message}"
};
config.AddTarget(blobStorageTarget);
var rule = new LoggingRule("*", LogLevel.Trace, blobStorageTarget);
config.LoggingRules.Add(rule);
LogManager.Configuration = config;
var logger = LogManager.GetCurrentClassLogger();

logger.Error("now we will soon log the longer String");
string myString = string.Concat(Enumerable.Range(0, 639).Select(i => "a"));

logger.Error(myString);

logger.Trace($"Trace msg at {DateTime.UtcNow:O}");
logger.Debug($"Debug msg at {DateTime.UtcNow:O}");
logger.Info($"Info msg at {DateTime.UtcNow:O}");
logger.Warn($"Warn msg at {DateTime.UtcNow:O}");
logger.Error($"Error msg at {DateTime.UtcNow:O}");

LogManager.Flush();

背景

此问题为同一异常的后续提问,此前已提交相关问题。

内容的提问来源于stack exchange,提问作者Sebastian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 06:47:22