you can swap different appenders in and out of log4j, that's the Strategy pattern
you make one logging call to log4j, and it notifies however many appenders there are congifured. the appenders are Observers
there are no doubt other patterns at work internally, but if this was an interview question, chances are they're looking for the above
> actually this question was given in an exam and the
> answer that the teacher gave was proxy pattern.
Actually, if you think about it, only the individuals that programmed the log4j code know what design patterns they actually used.
As an outsider, just because an application "looks" like a pattern might have been used, does not mean it was actually used to design the application.
Futhermore, just because an application's functionality may fit in well with how one envisions the pattern's possible implementation, this too, does automatically equate or represent the fact that the pattern(s) were used.
This is a poor question to have on an exam, especailly if the individuals taking the exam were not the ones that worked on log4j. If the exam was given to log4j programmers, then it is a reasonable question.
To ask this question to assess knowledge/experience with log4j or object-oriented design patterns is a bad decision, in my opinion.
Only close and detailed inspection of the log4j source code will reveal what design patterns were actually used. Again, to question someone on this is inappropriate, unless it is for the log4j development team, in my opinion.
> i m not able to understand how it applies proxy
> pattern?
I understand your confusion.