Wouldn't that application be the sort of thing to use 'nested diagnostic context' on?
NDC.push("filterable trans start message"); and pop the context in the 'finally' after the commit or rollback. On 6/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi, In my application, I wanted to use logging this way: 1. Use general log4j logging statement which goes to a project log file (It works fine). For e.g logger.getLogger( "ToolCli.class" ); 2. A special log which needs to be written to a separate file. Here we are not concerned about the log levels. We need only one level. Basically we need to log the summary of a particular transaction of our application. And those log statement for that particular transaction would come from different Java class files. To achive this I create another unique named logger and get this logger in the classes wherever I wanted to use it. This would result in having 2 Logger.getLogger in my class files. It solves my purpose but just wondering if my approach is fine? Please provide if you have any comments/suggestions. Thanks. Below is the sample code snippet: public class ToolCli { private static Logger logger = Logger.getLogger( "ToolCli.class ); private static Logger statusLogger = Logger.getLogger( "JobStatus" ); .... void myMethod() { statusLogger.info("Started Job..."); } void myMethod2() { logger.info("something to be logged..."); } } public class JobHandler { private static Logger logger = Logger.getLogger( "JobHandler.class ); private static Logger statusLogger = Logger.getLogger( "JobStatus" ); .... void myMethod() { statusLogger.info("Aborted Job..."); } void myMethod2() { logger.info("something to be logged..."); } } In log4j.xml apart from root logger JobStatus is defined as : <logger name="JobStatus" additivity="false" > <level value="DEBUG" /> <appender-ref ref="job"/> </logger> <root> <appender-ref ref="ConsoleAppender"/> <appender-ref ref="SyncTool"/> </root> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]