开发者

Can you have a log file per user with Enterprise Library 5 in Asp.net Mvc 2?

There w开发者_StackOverflowere 2 solutions suggested so far Environment variables using %username% in the filename section, and low level unmanaged code to accomplish it. Environment variables would be susceptible to pulling back only the user that is running the app (the server process login), not the form's login validated username or userGuid.

Has this been fixed or changed in EntLib 5? can I somehow configure a per user log within a category or categories? so that I can log App_Data/User1.Recordings.log and App_Data/User1.Category2.log, etc. ?


You can create you log files programmatically. Take a look at this link for a general reference:

http://www.davidhayden.com/blog/dave/archive/2006/02/14/2801.aspx

//Create filename
String fileName = <method_to_determine_logged_on_user> +".Recordings.log";

// Create a log file
Stream logFile = File.Create(fileName);

// Create the TextWriterTraceListener
TextWriterTraceListener listener = new TextWriterTraceListener(logFile);

// Add the listener to the list of TraceListeners
Trace.Listeners.Add(listener);

// Output the message
Trace.Write("My log message");

// Flush the output.
Trace.Flush(); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜