Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using log4net.Core;
using log4net.Layout.Pattern;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
public class HttpContextUserPatternConverter : PatternLayoutConverter
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
string name = "";
HttpContext context = HttpContext.Current;
if (context != null && context.User != null && context.User.Identity.IsAuthenticated)
name = context.User.Identity.Name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.