Something funny to end this week. When checking my Twitter feeds I found a kinky tweet about logging .NET Core messages to Notepad window. Yes, you heard right – .NET Core logger for Notepad. It’s not real, you want to say, but it is. And here’s how it works :)
The story of Notepad.Extensions.Logging
It’s a real deal – version 1.0.0, you see? :)
Notepad logger in action
Let’s get hands dirty with this little piece of art. Just create new ASP.NET Core web application and add Notepad.Extensions.Logging NuGet package. After this modify ConfigureServices() method in Startup like in following code fragment.
public void ConfigureServices(IServiceCollection services)
services.AddLogging(lb => lb.AddNotepad());
To try things out I made my HomeController log some messages.
public class HomeController : Controller
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
_logger = logger;
public IActionResult Index()
public IActionResult Privacy()
public override void OnActionExecuted(ActionExecutedContext context)
I didn’t made it work with NuGet package for some reason. I had to clone Notepad.Extensions.Logging repository to my machine and add it as project reference to web application. Then after few runs messages started appear to Notepad. Here’s the short video I made of this experiment.
So, it works after all!
Should I really use it?
Although this solution is funny it may still come handy when debugging something and there are things to dig out from logs frequently. It’s possible to disable all other log targets for debugging and skip logging related disk I/O as communication with Notepad goes directly through memory.
After using Notepad.Logging.Extensions few hours I actually started to like it. It’s weird but feels somehow convenient. Is Notepad the best choice for text editor? Who knows. But it’s not very hard to extend Notepad.Logging.Extensions to use some more advanced text editor.
Anyway, happy weekend and cheers!