Hi 3-eye,
The exception handling advice doesn't support that feature at the moment. I've added a JIRA issue to keep track of it. We will get a fix out much before the next release, I'll ping back here once it is done.
I've attached a solution with a few options. You'll need to copy supporting .dlls into the lib directory.
The first option is a copy of the existing implementation of ExceptionHandlerAdvice with a simple improvement that will let you configure the logging level used with the log action. (Unfortunately some methods I would have liked to override were private and not protected, I'll fix that as well so in the future you could subclass).
With the updated code you can configure the log level for all logging actions as shown below
Code:
<object name="exceptionHandlingAdvice" type="LoggingExample.Aspects.Exceptions.ExceptionHandlerAdvice, LoggingExample">
<property name="LogMethod" value="Info"/>
<property name="exceptionHandlers">
<list>
...
</list>
</property>
</object>
The expression syntax you used didn't work because you need to register a type alias for LogManager. The following bits of xml in App.config will do this for you.
Code:
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
<section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="assembly://LoggingExample/LoggingExample/application-config.xml"/>
</context>
<parsers>
<parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop" />
</parsers>
<typeAliases>
<alias name="LogManager" type="Common.Logging.LogManager, Common.Logging"/>
</typeAliases>
</spring>
Another option is to 'sneak' in some logging when you are performing exception translation. You can list multiple expressions (expression lists) to be evaluated, one of which could be a custom logging action. You need to enclose the multiple SpEL statement with parenthesis and separate each one with a semicolon. Here is an example configuration
Code:
<object name="exceptionHandlingAdvice" type="Spring.Aspects.Exceptions.ExceptionHandlerAdvice, Spring.Aop">
<property name="exceptionHandlers">
<list>
<value>on exception name ArithmeticException translate ( @(logHelper).LogException('Mylogger', LogLevel.Error, 'exception occured', #e); new System.ArithmeticException('wrapped bad math', #e) )</value>
</list>
</property>
</object>
The '@' syntax retrieves a spring managed object by name from the container.
If you want to go the route of using your own logging advice, you might want to consider using Spring's SimpleLoggingAdvice class. This class is 'subclass' friendly and should take care of much of the grunt work in implementing your own logging advice.
Cheers,
Mark