views:

182

answers:

1

There were 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. ?

A: 

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(); 
Robert Williams
and I can do this somewhere like the Global.asax so that any callers to the logger will have access to it?
Maslow
I would add this type of logic into a new, static logging class (e.g. Logger.cs). You could then write your logging method to accept a parameter for the message your logging as well as a parameter for the current userID, etc.. The static logging methods could be called from anywhere in your application.
Robert Williams