title: How to log to diferent files with Log4perl
body: <p>In perl, is there a way to log to two different files in different path?</p>
  
  <p>For example, I have to log detailed server queries and responses in a file and flow of the script in other file (the second file will have just the abstract information). How do I achieve this in Log4Perl.</p>
  
  <pre><code>sub getLogger
  {
      my ( $paramA, $paramB, $type ) = @_;
          my $conf = ("
              log4perl.rootLogger =INFO, LOGFILE
              log4perl.rootLogger1 =ALL, REPFILE
  
              log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
              log4perl.appender.LOGFILE.filename = sub { getLogFileName(\"$paramA\", \"$paramB\", \"$type\"); };
              log4perl.appender.LOGFILE.mode=append
              log4perl.appender.LOGFILE.autoflush = 1
              log4perl.appender.LOGFILE.size      = 1M
              log4perl.appender.LOGFILE.layout=PatternLayout
              log4perl.appender.LOGFILE.layout.ConversionPattern=[%c] %d %H - %m%n
  
              log4perl.appender.REPFILE=Log::Log4perl::Appender::File
              log4perl.appender.REPFILE.filename = sub { getLogFileName(\"$paramA\", \"$paramB\", \"$type\"); };
              log4perl.appender.REPFILE.mode=append
              log4perl.appender.REPFILE.autoflush = 1
              log4perl.appender.REPFILE.size      = 1M
              log4perl.appender.REPFILE.layout=PatternLayout
              log4perl.appender.REPFILE.layout.ConversionPattern=[%c] %d %H - %m%n
          ");
          Log::Log4perl::init(\$conf);
          my $logger1 = Log::Log4perl-&gt;get_logger('rootLogger');
          my $logger2 = Log::Log4perl-&gt;get_logger('rootLogger1');
          if($type == 1)
          {
              return $logger1;
          }
          else
          {
              return $logger2;
          }
  }
  </code></pre>
  
  <p>When I try to get logger1 and logger2 at different places of the script, the last obtained instance copies to both loggers. For example,</p>
  
  <pre><code>my $logger1 = getLogger($paramA, $paramB, $type);
  $logger1-&gt;info("This is log 1"); #printed in file 1 correctly
  my $logger2 = getLogger($paramA, $paramB, $type);
  $logger2-&gt;info("This is log 2"); #printed in file 2 correctly
  $logger1-&gt;info("Again trying to print in file1"); #printed in file2 - expected to print in file1.
  $logger2-&gt;info("Again trying to print in file2"); #printed in file2 - expected to print in file2.
  </code></pre>
  
  <p>I am stuck here. What is going wrong?!</p>