Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I may be completely off base on my understanding of what you are attempting to accomplish, but I will take a stab at the solution. It sounds like you want a separate log file for each country for which you are processing email. Based on that understanding, here is a possible solution:</p> <ol> <li><p>Set up an appender in your log4j configuration for each country for which you wish to log separately (US example provided):</p> <p>log4j.appender.usfile=org.apache.log4j.FileAppender</p> <p>log4j.appender.usfile.File=us.log</p> <p>log4j.appender.usfile.layout=org.apache.log4j.PatternLayout</p> <p>log4j.appender.usfile.layout.ConversionPattern=%m%n</p></li> <li><p>Create a logger for each country and direct each of them to the appropriate appender (US example provided):</p> <p>log4j.logger.my-us-logger=debug,usfile</p></li> <li><p>In your code, create your Logger based on the country for which the email is being processed:</p> <p>Logger logger = Logger.getLogger("my-us-logger");</p></li> <li><p>Determine how you will accomplish step 3 for the subsequent method calls. You could repeat step 3 in each class/method; or you could modify the method signatures to accept a Logger as input; or you could possibly use <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ThreadLocal.html" rel="nofollow noreferrer">ThreadLocal</a> to pass the Logger between methods.</p></li> </ol> <p>Extra info: If you do not want the log statements going to parent loggers (e.g. the rootLogger), you can set their additivity flags to false (US example provided):</p> <pre><code>log4j.additivity.my-us-logger=false </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload