problem with log

mrde
edited September 2011 in Photon Server
Hi.
I use Photon rc3
my setup code is...
// log4net
string path = Path.Combine(this.BinaryPath, "log4net.config");
var file = new FileInfo(path);
if (file.Exists) {
      LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
      XmlConfigurator.ConfigureAndWatch(file);
}

and log4net.config is
<?xml version="1.0" encoding="utf-8" ?>
<log4net debug="true">

  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %-30.30c{2} %m% [%t] [%x]%n" />
    </layout>
  </appender>
  
	<!-- "normal" log file appender -->
	<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
		<param name="File" value="log\BoxBall.log" />
		<param name="AppendToFile" value="true" />
		<param name="MaxSizeRollBackups" value="1" />
		<param name="MaximumFileSize" value="250MB" />
		<param name="RollingStyle" value="Size" />
    <param name="LockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
			<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
		</layout>
	</appender>

  <!-- performance counter log file appender -->
  <appender name="CounterAppender" type="log4net.Appender.RollingFileAppender">
    <param name="File" value="log\BoxBallCounter.log" />
    <param name="AppendToFile" value="true" />
    <param name="MaxSizeRollBackups" value="1" />
    <param name="MaximumFileSize" value="1MB" />
    <param name="RollingStyle" value="Size" />
    <param name="StaticLogFileName" value="true" />
    <param name="LockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d{ABSOLUTE} %m%n" />
    </layout>
  </appender>

  <!-- logger -->
  
  <root>
    <level value="DEBUG" />
    <appender-ref ref="LogFileAppender" /> 
    <appender-ref ref="ConsoleAppender" />
	</root>

  <!-- operation data logger -->
  <!-- set level to DEBUG to enable operation data logging-->
  <logger name="OperationData" additivity="false">
    <level value="DEBUG" />
    <appender-ref ref="LogFileAppender" />
  </logger>

  <!-- performance counter logger -->
  <!-- set level to DEBUG to enable performance counter logging-->
  <logger name="PerformanceCounter" additivity="false">
    <level value="DEBUG" />
    <appender-ref ref="CounterAppender" />
  </logger>
  
  
  <!--
  <root>
    <level value="INFO" />
    <appender-ref ref="LogFileAppender" /> 
    <appender-ref ref="ConsoleAppender" />
	</root>

  <!-- operation data logger -->
  <!-- set level to DEBUG to enable operation data logging-->
  <logger name="OperationData" additivity="false">
    <level value="INFO" />
    <appender-ref ref="LogFileAppender" />
  </logger>

  <!-- performance counter logger -->
  <!-- set level to DEBUG to enable performance counter logging-->
  <logger name="PerformanceCounter" additivity="false">
    <level value="INFO" />
    <appender-ref ref="CounterAppender" />
  </logger>
  -->

</log4net>

in BasePeer.cs inhered class.

protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
if (log.IsDebugEnabled) {
log.DebugFormat("OnOperationRequest. klor Code={0}", operationRequest.OperationCode);
}
......

I newer see my logs in "deploy\log\BoxBallCounter.log" file, why???

Thanks.

Comments

  • did you make sure that log4net.config is copied to the output directory? (does it exist in your bin folder?)
  • Yes I am sure


    I checked go into if equation

    string path = Path.Combine(this.BinaryPath, "log4net.config");
    var file = new FileInfo(path);
    if (file.Exists) {
    // code do this if equation
    ...
  • the xml seems to be broken, when i paste it into VS it says:
    Error 1 Character sequence '--' is illegal inside XML comments. 67 5
    try removing the xml comment.
  • Crazy. You are right. Problem was in my xml. :lol:

    Thank you very much.