ConnectionMultiplexer.Connect() optionally accepts a TextWriter for logging.

Answer from tstuts on Stack Overflow
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis
StackExchange.Redis | General purpose redis client
StackExchange.Redis can be installed via the nuget UI (as StackExchange.Redis), or via the nuget package manager console: ... Compare-And-Swap / Compare-And-Delete (CAS/CAD) - atomic conditional operations using value comparison · Events - the events available for logging / information purposes
🌐
GitHub
github.com › StackExchange › StackExchange.Redis › issues › 164
Add logging support via Common.Logging · Issue #164 · StackExchange/StackExchange.Redis
February 17, 2015 - Replace TextWriter with Common.Logging. This will add more flexibility for managing internal logging.
Author   cd21h
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis › RespLogging.html
Logging and validating the underlying RESP stream | StackExchange.Redis
An exception here is strong evidence that there is a fault either in the redis server, or an intermediate proxy. Conversely, if the library reported a protocol failure but the validation step here does not report an error, then that is strong evidence of a library error; please report this (with details). You can also replay the conversation locally, seeing the individual requests and responses: var messages = await LoggingTunnel.ReplayAsync(@"C:\Code\RedisLog", (cmd, resp) => { if (cmd.IsNull) { // out-of-band/"push" response Console.WriteLine("<< " + LoggingTunnel.DefaultFormatResponse(resp)); } else { Console.WriteLine(" > " + LoggingTunnel.DefaultFormatCommand(cmd)); Console.WriteLine(" < " + LoggingTunnel.DefaultFormatResponse(resp)); } }); Console.WriteLine($"{messages} RESP commands validated");
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis › Events.html
Events | StackExchange.Redis
The ConnectionMultiplexer type exposes multiple events that can be used to understand what is happening under the covers. This can be useful in particular for logging purposes.
🌐
GitHub
github.com › StackExchange › StackExchange.Redis › issues › 2473
Support for Microsoft.Extensions.Logging.ILogger in ConnectionMultiplexer · Issue #2473 · StackExchange/StackExchange.Redis
May 27, 2023 - Currently all the implementations of ConnectionMultiplexer accepts TextWriter as an optional input to print the logs while creating the multiplexer. This is not compatible with .NetCore services using ILogger Reference File - https://github.com/StackExchange/StackExchange.Redis/blob/main/src/StackExchange.Redis/ConnectionMultiplexer.cs#L650
Published   May 27, 2023
Author   AmrutaMoghe
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis › Configuration.html
Configuration | StackExchange.Redis
Likewise, when the configuration ... INFO, CONFIG, etc - where available). StackExchange.Redis does this by automatically subscribing to a pub/sub channel upon which such notifications may be sent....
🌐
Mintlify
mintlify.com › mintlify atlas › mintlify-atlas/docs-atlas-3140b850 › aspire.stackexchange.redis
Aspire.StackExchange.Redis - .NET Aspire
The Aspire.StackExchange.Redis component registers an IConnectionMultiplexer in your dependency injection container for connecting to Redis servers. It automatically enables health checks, logging, and distributed tracing.
🌐
NuGet
nuget.org › packages › Aspire.StackExchange.Redis
NuGet Gallery | Aspire.StackExchange.Redis 13.2.1
#addin nuget:?package=Aspire.StackExchange.Redis&version=13.2.1 ... The NuGet Team does not provide support for this client. Please contact its maintainers for support. ... Registers an IConnectionMultiplexer in the DI container for connecting to Redis®* server. Enables corresponding health check, logging, and telemetry.
Find elsewhere
🌐
GitHub
github.com › StackExchange › StackExchange.Redis › issues › 1811
Proposal: Enable a default connection logger · Issue #1811 · StackExchange/StackExchange.Redis
July 20, 2021 - Currently ConnectionMultiplexer supports outputting logs from connect/reconnect operations. This is helpful for debugging connections issues, but it's difficult to discover and use this capability. Users need to create a TextWriter instance and pass it in to the .Connect() call.
Author   philon-msft
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis › Basics.html
Basic Usage | StackExchange.Redis
Note: exceptions are caught and discarded by StackExchange.Redis here, to prevent cascading failures.
🌐
NuGet
nuget.org › packages › StackExchange.Redis
NuGet Gallery | StackExchange.Redis 2.11.8
Code: https://github.com/StackExchange/StackExchange.Redis/ ... Included target framework(s) (in package) Learn more about Target Frameworks and .NET Standard. Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
Top answer
1 of 2
4

Interesting challenge (!) because dates are sparse.

Here's a thought: if you can find a way to represent dates as numbers (minutes past the year 2000?), then you could try a Sorted Set. The set would be keyed on the user ID. The score would be the numeric date representation. The value would be the log entry.

Then you can use ZRANGEBYSCORE to get log entries within a date range. Also, it should be easy/efficient to "get the N most recent log entries".

Example: ZADD user:23432:activity 1363800946 data

2 of 2
1

I'm one of the authors of the Feedly package which was mentioned.

We built a solution for the 2nd largest online fashion community and open sourced our approach: https://github.com/tschellenbach/Feedly It's currently the largest open source library aimed at solving this problem. You can use both Redis and Cassandra as storage backends.

Our redis storage backend uses sorted sets for data storage. https://github.com/tschellenbach/Feedly/tree/master/feedly/storage/redis In addition we use pubsub capabilities for the realtime components.

The same team which built Feedly also offers a hosted API, which handles the complexity for you. Have a look at getstream.io There are client libraries for Python, PHP, Node and Ruby. (This is based on Cassandra and therefore substantially cheaper to operate than running your own system using Redis)

In addition have a look at this high scalability post were we explain some of the design decisions involved: http://highscalability.com/blog/2013/10/28/design-decisions-for-scaling-your-high-traffic-feeds.html

This tutorial will help you setup a system like Pinterest's feed using Redis. It's quite easy to get started with.

To learn more about feed design I highly recommend reading some of the articles which we based Feedly on:

  • Yahoo Research Paper
  • Twitter 2013 Redis based, with fallback
  • Cassandra at Instagram
  • Etsy feed scaling
  • Facebook history
  • Django project, with good naming conventions. (But database only)
  • http://activitystrea.ms/specs/atom/1.0/ (actor, verb, object, target)
  • Quora post on best practises
  • Quora scaling a social network feed
  • Redis ruby example
  • FriendFeed approach
  • Thoonk setup
  • Twitter's Approach
🌐
StackExchange.Redis
stackexchange.github.io › StackExchange.Redis › ReleaseNotes.html
Release Notes | StackExchange.Redis - Stack Overflow OSS
Adds: RESP3 support (#2396 by mgravell) ...github.io/StackExchange.Redis/Resp3 · Fix #2507: Pub/sub with multi-item payloads should be usable (#2508 by mgravell) Add: connection-id tracking (internal only, no public API) (#2508 by mgravell) Add: ConfigurationOptions.LoggerFactory for logging ...
🌐
Huawei Cloud
support.huaweicloud.com › help center › distributed cache service › user guide › accessing a dcs redis instance › connecting to redis on a client › connecting to redis on stackexchange.redis (c#)
Connecting to Redis on StackExchange.Redis (C#)_Connecting to Redis on a Client_Accessing a DCS Redis Instance_User Guide_Distributed Cache Service-Huawei Cloud
November 5, 2025 - Log in to the ECS. A Windows ECS is used as an example. Install Visual Studio Community 2017 on the ECS. Start Visual Studio 2017 and create a project. Set the project name to redisdemo. Install StackExchange.Redis by using the NuGet package manager of Visual Studio.
🌐
Elastic
elastic.co › elastic docs › reference › ingestion tools › apm › apm agents › apm .net agent › nuget packages › stackexchange.redis
StackExchange.Redis | APM .NET Agent Reference [1.x]
Instrumentation can be enabled for StackExchange.Redis by referencing Elastic.Apm.StackExchange.Redis package and calling the UseElasticApm() extension method defined in Elastic.Apm.StackExchange.Redis, on IConnectionMultiplexer · A callback is registered with the IConnectionMultiplexer to ...
🌐
GitHub
github.com › StackExchange › StackExchange.Redis › issues › 2202
Provision to log operation duration · Issue #2202 · StackExchange/StackExchange.Redis
July 29, 2022 - I can't wrap any logic around the redis operation itself and we'd need that to get a start/end time and calculate an operation duration. ... We provider a profiling implementation here: https://stackexchange.github.io/StackExchange.Redis/Profiling_v2.html - if you want to capture that's a way to do it.
🌐
GitHub
github.com › StackExchange › StackExchange.Redis › blob › main › src › StackExchange.Redis › ConfigurationOptions.cs
StackExchange.Redis/src/StackExchange.Redis/ConfigurationOptions.cs at main · StackExchange/StackExchange.Redis
using Microsoft.Extensions.Logging; using StackExchange.Redis.Configuration; · namespace StackExchange.Redis · { /// <summary> /// The options relevant to a set of redis connections.
Author   StackExchange
🌐
GitHub
github.com › StackExchange › StackExchange.Redis
GitHub - StackExchange/StackExchange.Redis: General purpose redis client · GitHub
StackExchange.Redis is a .NET client for communicating with RESP servers such as Redis, Azure Managed Redis, Garnet, Valkey, AWS ElastiCache, and a wide range of other Redis-like servers. We do not maintain a list of compatible servers, but if the server has a Redis-like API: it will probably work fine. If not: log an issue with details!
Starred by 6.1K users
Forked by 1.6K users
Languages   C#
🌐
NuGet
nuget.org › packages › StackExchange.Redis.Extensions.Core
NuGet Gallery | StackExchange.Redis.Extensions.Core 11.0.0
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications. To store complex data It requires one of the...