views:

751

answers:

3

We are using log4net (replacing nLog) in our Asp.Net web application. nLog had a useful feature that would allow us to create a log file per user - which is helpful for organizing and locating the log statements.

Does anyone have any ideas on how to do this with log4net?

+4  A: 

Instead of logging to a file, think about logging to a database table and have the user id part of the logged data. This way you can do selects against the table based on the user (or users) and see only their data. Probably also want to log the session id, too, to make session based queries easy.

tvanfosson
+1  A: 

One way would be to write your own appender such deriving from RollingFileAppender

Preet Sangha
A: 

Instantiate a new RollingFileAppender programmatically in the session_start event handler in the global.asax file. This way you can get one different file for every single user, naming the files [username]myapp.log , for example. I know, it's an old question, but it could always be handy for somebody :)

themarcuz