iis - How to write a log on an ASP.NET website virtual directory? -
my website running asp.net user in iis. i've created 1 virtual directory, 'logs', internally pointing shared drive folder access limited number of users. how can create log file on virtual directory log4net?
do (or can i) provide user credentials when create logger or file?
it looks there's no problem writing log files virtual directory on website. tell log4net path relative current directory writing configuration
<appender ...> <file value="logs\website.log" /> </appender>
now, if want put current username in log message, you'll want investigate log4net contexts. stashing current user in log4net context
log4net.threadcontext.properties["user"] = httpcontext.cache["current-user"];
and pulling out in appender layout
<appender ...> <layout ...> <conversionpattern value="%date %-5level [%property{user}] %message%newline" /> </layout> </appender>
Comments
Post a Comment