﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>John Simons commented on Logging - the AOP way</title><description>Thanks Oren, I'll have a look at that post
</description><link>http://ayende.com/3474/logging-the-aop-way#comment15</link><guid>http://ayende.com/3474/logging-the-aop-way#comment15</guid><pubDate>Mon, 22 Sep 2008 22:07:32 GMT</pubDate></item><item><title>Ayende Rahien commented on Logging - the AOP way</title><description>This has nothing to do with AOP, actually.
  
You need to handle that using simple repository base class.
  
You can see another solution to this here:
  
[ayende.com/.../...xtending-NHibernate-Proxies.aspx](http://ayende.com/Blog/archive/2007/04/17/Advance-Extending-NHibernate-Proxies.aspx)</description><link>http://ayende.com/3474/logging-the-aop-way#comment14</link><guid>http://ayende.com/3474/logging-the-aop-way#comment14</guid><pubDate>Mon, 22 Sep 2008 10:44:36 GMT</pubDate></item><item><title>John Simons commented on Logging - the AOP way</title><description>Sorry Orien that I'm not making myself clear.
  
  
Let's say that I have:
  
  
 public class UserRepository : IUserRepository
  
 {
  
		public void Save(User user)
  
		{
  
		}
  
  
		User Load(string username){}
  
 }
  
and User is:
  
class User {
  
 string username,
  
 string FirstName,
  
 string LastName,
  
 ....	
  
}
  
  
If I want to audit on the Save method and audit what the value was before and after I would have to write something like this:
  
public void Save(User user)
  
{
  
	User userBeforeChange = Load(user.Username);
  
	....
  
	Audit.Write("FirstName Before={0}, After={1}", userBeforeChange.Firstname, user.Firstname);
  
}
  
  
I guess my question is how can I use AOP in this case instead of having to write the code above on every IRepository ?
</description><link>http://ayende.com/3474/logging-the-aop-way#comment13</link><guid>http://ayende.com/3474/logging-the-aop-way#comment13</guid><pubDate>Mon, 22 Sep 2008 08:03:26 GMT</pubDate></item><item><title>Ayende Rahien commented on Logging - the AOP way</title><description>You intercept property changes and write them to the audit table.
  
I am not sure that I understand what the problem is.
  
</description><link>http://ayende.com/3474/logging-the-aop-way#comment12</link><guid>http://ayende.com/3474/logging-the-aop-way#comment12</guid><pubDate>Mon, 22 Sep 2008 06:29:37 GMT</pubDate></item><item><title>John Simons commented on Logging - the AOP way</title><description>Can you give me some pointers ?
  
  
My audit table is something like this:
  
  
Changed By=jsimons
  
At=12 Mar 2008 18:00
  
Type Of Object Modified=User
  
ObjectKey=scropp
  
Data Modified= 
  
		Last Name
  
			Before = Cropp
  
			After = Smith
  
		.....
  
  
So that I can query it by saying something like: Who was the last person to modify the LastName of a User  with username=scropp?
  
  
Also, my repository is Active Directory and the auditing data is kept in sql.
  
I've been thinking about this problem for a while, and I don't seem to come up with a clean solution that does not involve adding extra code to each of my models (User, Group,....) that require auditing.
  
Any help would be very appreciated :)
</description><link>http://ayende.com/3474/logging-the-aop-way#comment11</link><guid>http://ayende.com/3474/logging-the-aop-way#comment11</guid><pubDate>Mon, 22 Sep 2008 06:16:44 GMT</pubDate></item><item><title>Ayende Rahien commented on Logging - the AOP way</title><description>Yes, it can be.
</description><link>http://ayende.com/3474/logging-the-aop-way#comment10</link><guid>http://ayende.com/3474/logging-the-aop-way#comment10</guid><pubDate>Mon, 22 Sep 2008 03:54:07 GMT</pubDate></item><item><title>John Simons commented on Logging - the AOP way</title><description>Just wondering if the same technique can be applied for auditing?
  
</description><link>http://ayende.com/3474/logging-the-aop-way#comment9</link><guid>http://ayende.com/3474/logging-the-aop-way#comment9</guid><pubDate>Sun, 21 Sep 2008 22:44:34 GMT</pubDate></item><item><title>Ayende Rahien commented on Logging - the AOP way</title><description>1) the test code is not the code that is intrecepted, it is the code that is using the intercepted component.
  
2) pretty much, I something do extra stuff when it is really required. Very rare, though
  
3) logger per type
</description><link>http://ayende.com/3474/logging-the-aop-way#comment8</link><guid>http://ayende.com/3474/logging-the-aop-way#comment8</guid><pubDate>Tue, 05 Aug 2008 23:30:48 GMT</pubDate></item><item><title>Sammy commented on Logging - the AOP way</title><description>I have a couple of questions please:
  
1. In your test code, you have an empty catch block. I always thought this will block invocation.Proceed() from catching the exception itself. Am I wrong?
  
2. Do you use AOP for ALL your application logging? If you don't, what kind of logging would you do inline - that is, within the function code?
  
3. Do you retrieve a Logger for each type of class usually, or would you recommend having a logger type for, for instance, the whole assembly?
  
Thanks!
</description><link>http://ayende.com/3474/logging-the-aop-way#comment7</link><guid>http://ayende.com/3474/logging-the-aop-way#comment7</guid><pubDate>Tue, 05 Aug 2008 09:18:44 GMT</pubDate></item><item><title>Gauthier Segay commented on Logging - the AOP way</title><description>you may want to bypass or cribble some arguments such as one named password or having [DoNotLog] meta attribute.
</description><link>http://ayende.com/3474/logging-the-aop-way#comment6</link><guid>http://ayende.com/3474/logging-the-aop-way#comment6</guid><pubDate>Fri, 01 Aug 2008 19:09:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Logging - the AOP way</title><description>Rik, _really_ nice
</description><link>http://ayende.com/3474/logging-the-aop-way#comment5</link><guid>http://ayende.com/3474/logging-the-aop-way#comment5</guid><pubDate>Fri, 01 Aug 2008 10:21:38 GMT</pubDate></item><item><title>Rik Hemsley commented on Logging - the AOP way</title><description>The code using StringBuilder smelled, so I had to do this:
  
  
logger.Debug
  
(
  
    "{0}.{1}({2})",
  
    invocation.TargetType.FullName,
  
    invocation.Method,
  
    string.Join(", ", invocation.Arguments.ToArray())
  
 );
  
</description><link>http://ayende.com/3474/logging-the-aop-way#comment4</link><guid>http://ayende.com/3474/logging-the-aop-way#comment4</guid><pubDate>Fri, 01 Aug 2008 09:47:06 GMT</pubDate></item><item><title>Torkel commented on Logging - the AOP way</title><description>Yes, I love this usage of AOP. I used this approach to trace all in/out communication to a SAP RFC interface, with 40+ methods, each method having 5-15 arguments. The logging code for the SAP interface was huge when I started on the project and yet it did seldom include the relevant information. 
  
  
By using this AOP approach I could remove all that duplicated logging code and at the same time be able to turn on/off logging and serialize all the arguments and return values to xml (and save in db), this made production troubleshooting so much easier! 
</description><link>http://ayende.com/3474/logging-the-aop-way#comment3</link><guid>http://ayende.com/3474/logging-the-aop-way#comment3</guid><pubDate>Fri, 01 Aug 2008 07:37:00 GMT</pubDate></item><item><title>Tobin Harris commented on Logging - the AOP way</title><description>Thanks Ayende, that's a great example and I'm looking forward to trying it out :)
</description><link>http://ayende.com/3474/logging-the-aop-way#comment2</link><guid>http://ayende.com/3474/logging-the-aop-way#comment2</guid><pubDate>Thu, 31 Jul 2008 21:54:21 GMT</pubDate></item><item><title>Davy Brion commented on Logging - the AOP way</title><description>AOP and Logging are great together... check out the following post on how you can easily log each method's incoming parameters, and its return value:
  
  
http://davybrion.com/blog/2008/05/adding-behavior-with-postsharp/
  
  
i wouldn't use that in production, but for debugging it's great
</description><link>http://ayende.com/3474/logging-the-aop-way#comment1</link><guid>http://ayende.com/3474/logging-the-aop-way#comment1</guid><pubDate>Thu, 31 Jul 2008 21:16:24 GMT</pubDate></item></channel></rss>