logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Richardson <RDRichard...@rad-con.com>
Subject RE: Writing to two different log files
Date Fri, 27 Jun 2014 13:01:24 GMT
That didn't work for me.  Here's the configuration file I tried:

<?xml version="1.0" encoding="utf-8"?>
<log4net>
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file value="CraneSimulator_Console.log" />
    <appendToFile value="true" />
    <maxSizeRollBackups value="90" />
    <rollingStyle value="Size" />

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date - %message%newline" />
    </layout>
  </appender>

  <appender name="RollingFile_sim" type="log4net.Appender.RollingFileAppender">
    <file value="CraneSimulator_Console_sim.log" />
    <appendToFile value="true" />
    <maxSizeRollBackups value="90" />
    <rollingStyle value="Size" />

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date - %message%newline" />
    </layout>
  </appender>
</appender>

<logger name="BaseLogger">
  <level value="DEBUG" />
  <maximumfilesize value="256KB" />
  <param value="DEBUG" name="Threshold" />

  <appender-ref ref="RollingFile" />
</logger>

<logger name="SimLogger">
  <level value="DEBUG" />
  <maximumfilesize value="256KB" />
  <param value="DEBUG" name="Threshold" />

  <appender-ref ref="RollingFile_sim" />
</logger>

<!--
  <root>
     <level value="DEBUG" />
     <appender-ref ref="RollingFile" />
     <appender-ref ref="RollingFile_sim" />
  </root>
-->

</log4net>

And the code I was trying to use it in:

            public CraneSimulator_Console(string xmlFileName)
            {
                  System.IO.FileInfo logConfigFile = new System.IO.FileInfo(Environment.CurrentDirectory
+
                                                                    //"/cranesimulator_console_log_config.xml");
                                                                    "multiple_files.xml");
                  XmlConfigurator.ConfigureAndWatch(logConfigFile);
                  ILog m_logger = LogManager.GetLogger("BaseLogger");
                  ILog simLogger = LogManager.GetLogger("SimLogger");
                  m_logger.Info("This is from cranesimulator_console.");
                  simLogger.Info("This should be in the sim logger.");
            }

RobR

Mime
View raw message