Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchSize in appsettings.json not working? #155

Open
symlynk opened this issue May 14, 2024 · 5 comments
Open

BatchSize in appsettings.json not working? #155

symlynk opened this issue May 14, 2024 · 5 comments

Comments

@symlynk
Copy link

symlynk commented May 14, 2024

How would I go about setting the batchSize and taskDelayMilliseconds using appsettings.json? The following doesn't appear to be working as I'm hitting the 50000 block limit with similar number of lines in the log no matter what values I use.

"NLog": {
	"extensions": [
		{
			"assembly": "NLog.Web.AspNetCore"
		},
		{
			"assembly": "NLog.Extensions.AzureBlobStorage"
		}
	],
	"targets": {
		"blob": {
			"type": "AzureBlobStorage",
			"blobName": "${logger}/${shortdate:universalTime=True}.log",
			"connectionString": "${configsetting:ConnectionStrings.Storage}",
			"container": "logs",
			"batchSize": 1000,
			"taskDelayMilliseconds": 1000
		}
	},
	"rules": [
		{
			"logger": "*",
			"minLevel": "Trace",
			"writeTo": "blob"
		}
	]
}
@snakefoot
Copy link
Contributor

I'm not an expert on Azure Blob Storage, so you will probably find better advice on StackOverflow.com

When troubleshooting NLog then it is always a good idea to enable "throwConfigExceptions": true. It can also be a good idea to enable NLog InternalLogger to see what NLog Configuration is applied.

Are you by any chance running multiple nodes against the same Azure-Blob, thus having multiple nodes performing 30000 appends, thus exceeding the max total of 50000 writes ?

@symlynk
Copy link
Author

symlynk commented May 14, 2024

The internal log shows no errors or any mention of batchSize or taskDelayMilliseconds using "internalLogLevel": "trace" and "throwConfigExceptions": true. I can see the target being successfully registered.

There is only a single instance of the application writing to this log which is writing around 2000 lines per second in trace mode.

@snakefoot
Copy link
Contributor

snakefoot commented May 15, 2024

If you write 2000 lines/per-sec, and using BatchSize=1000, then I guess you are performing 2 appends-per-sec.

And single blob can only handle 50000-appends, and you create single blob-per-day. So 50000 / 24 hours / 60 min = Max 34 appends-per-min.

Maybe change from daily to hourly: "blobName": "${logger}/${date:format=yyyy-MM-dd-HH:universalTime=true}.log"

@snakefoot
Copy link
Contributor

@snakefoot
Copy link
Contributor

snakefoot commented May 16, 2024

You probably have to increase taskDelayMilliseconds to avoid trigger write before having a full batchSize:

		"blob": {
			"type": "AzureBlobStorage",
			"blobName": "${logger}/${shortdate:universalTime=True}.log",
			"connectionString": "${configsetting:ConnectionStrings.Storage}",
			"container": "logs",
			"batchSize": 10000,
			"taskDelayMilliseconds": 5000
		}

Again probably easier to change from daily to hourly: "blobName": "${logger}/${date:format=yyyy-MM-dd-HH:universalTime=true}.log"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants