Cassie Mod

Cassie Mod

  • NA
  • 488
  • 70.5k

log4net nog logging

Dec 20 2016 7:07 AM

    1. <?xml version="1.0" encoding="utf-8" ?>  
    2. <configuration>  
    3.     <configSections>  
    4.     </configSections>  
    5.   <appSettings>  
    6.     <add key="log4net.Config" value="log4net.config"/>  
    7.     <add key="log4net.Config.Watch" value="True"/>  
    8.     <add key="log4net.Internal.Debug" value="False"/>  
    9.   </appSettings>  
    10.     <connectionStrings>  
    11.         <add name="WindowsFormsApplication1.Properties.Settings.CLAConnectionsConnectionString"  
    12.             connectionString="Data Source=MAC-CASPER\SQLSERVERCASPER;Initial Catalog=CLAConnections;User ID=Defcon;Password=0000"  
    13.             providerName="System.Data.SqlClient" />  
    14.     </connectionStrings>  
    15. </configuration>  
    <?xml version=
    "1.0" encoding="utf-8" ?>  
  1. <configuration>  
  2.   <configSections>  
  3.     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />  
  4.   </configSections>  
  5.   
  6.   <log4net>  
  7.     <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">  
  8.       <file value="C:\Logs\log.txt" />  
  9.       <appendToFile value="true" />  
  10.       <rollingStyle value="Size" />  
  11.       <maxSizeRollBackups value="10" />  
  12.       <maximumFileSize value="250KB" />  
  13.       <staticLogFileName value="true" />  
  14.       <layout type="log4net.Layout.PatternLayout">  
  15.         <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />  
  16.       </layout>  
  17.     </appender>  
  18.     <root>  
  19.       <level value="ALL" />  
  20.       <appender-ref ref="RollingFileAppender" />  
  21.     </root>  
  22.   </log4net>  
  23.   
  24. </configuration>  
 Hi guys, i'm doing something wrong but I don't know what.

I use log4 net for logging.

 
I made a class called Logger:
 
  1. using System;  
  2. using log4net;  
  3.   
  4. namespace WindowsFormsApplication1.Core  
  5. {  
  6.     public class Logger  
  7.     {  
  8.         private static ILog Log { get; set; }  
  9.   
  10.         static Logger()  
  11.         {  
  12.             Log = LogManager.GetLogger(typeof(Logger));  
  13.         }  
  14.   
  15.         public static void Error(object msg)  
  16.         {  
  17.             Log.Error(msg);  
  18.         }  
  19.   
  20.         public static void Error(object msg, Exception ex)  
  21.         {  
  22.             Log.Error(msg, ex);  
  23.         }  
  24.   
  25.         public static void Error(Exception ex)  
  26.         {  
  27.             Log.Error(ex.Message, ex);  
  28.         }  
  29.   
  30.         public static void Info(object msg)  
  31.         {  
  32.             Log.Info(msg);  
  33.         }  
  34.     }  
  35. }  

And I can call it true logger.Error(ex);

 
However it is not logging anything ?? so what am I doing wrong ?
 

Answers (3)