[
https://issues.apache.org/jira/browse/LOG4NET-224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dominik Psenner resolved LOG4NET-224.
-------------------------------------
Resolution: Invalid
Fix Version/s: (was: 1.2 Maintenance Release)
Please refer to the FAQ and configuration examples on the log4net web page. If
that doesn't mention your usecase, ask questions in one of the mailing lists.
> After implementing Log4net the application works fine but cannot see the log
> file created
> -----------------------------------------------------------------------------------------
>
> Key: LOG4NET-224
> URL: https://issues.apache.org/jira/browse/LOG4NET-224
> Project: Log4net
> Issue Type: Task
> Environment: Windows Server 2003, .NET 3.5
> Reporter: Amit Viraktamath
>
> Hi,
> I have created a wrapper to the Log4net and used in my SharePoint webpart. I
> am developing in .NET 3.5 framework on windows server 2003 platform. After I
> deploy my webpart the web part works fine. however the logfine is not seen at
> the configured path. Also there are no errors in the event viewer. Could you
> please review the following code and suggest what is missing?
> WEB.CONFIG file entries
> <configSections>
> <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler,log4net-net-1.0"/>
> </configSections>
> <log4net>
> <logger name="Log4netLoggingFramework">
> <level value="INFO"/>
> </logger>
> <root>
> <level value="INFO" />
> <appender-ref ref="LogFileAppender" />
> <appender-ref ref="ConsoleAppender" />
> </root>
> <appender name="LogFileAppender"
> type="log4net.Appender.FileAppender" >
> <param name="File"
> value="C:\Inetpub\wwwroot\wss\VirtualDirectories\31569\logfile.log" />
> <param name="AppendToFile" value="true" />
> <layout type="log4net.Layout.PatternLayout">
> <param name="Header" value="[Header]\r\n"/>
> <param name="Footer" value="[Footer]\r\n"/>
> <param name="ConversionPattern" value="%d [%t] %-5p %c
> [%x]<%X{auth}> - %m%n"/>
> </layout>
> <filter type="log4net.Filter.LevelRangeFilter">
> <param name="LevelMin" value="INFO" />
> <param name="LevelMax" value="WARN" />
> </filter>
> </appender>
> <appender name="ConsoleAppender"
> type="log4net.Appender.ConsoleAppender" >
> <layout type="log4net.Layout.PatternLayout">
> <param name="ConversionPattern" value="%d [%t] %-5p %c [%x]
> <%X{auth}> - %m%n" />
> </layout>
> </appender>
> </log4net>
> Following is the C# code that wraps the requests to Log4net dll
> --- CODE START --
> namespace Log4netLoggingFramework
> {
> public static class LogInfo
> {
> public enum LogType { Debug = 1, Error = 2, Info = 3, Fatal = 4};
> public static void Log(string logMessage, int logType)
> {
> //if (logType == LogType.Debug)
> //{
> // DebugLog dlog = new DebugLog();
> // dlog.DoLogging(logMessage);
> //}
> //else if (logType == LogType.Info)
> //{
> // InfoLog ilog = new InfoLog();
> // ilog.DoLogging(logMessage);
> //}
> //else if (logType == LogType.Error)
> //{
> // ErrorLog elog = new ErrorLog();
> // elog.DoLogging(logMessage);
> //}
> if (logType == 1)
> {
> DebugLog dlog = new DebugLog();
> dlog.DoLogging(logMessage);
> }
> else if (logType == 2)
> {
> InfoLog ilog = new InfoLog();
> ilog.DoLogging(logMessage);
> }
> else if (logType == 3)
> {
> ErrorLog elog = new ErrorLog();
> elog.DoLogging(logMessage);
> }
> }
> }
> public class DebugLog
> {
> private static readonly ILog logger =
> LogManager.GetLogger(typeof(DebugLog));
> /// <summary>
> /// Constructor for the DebugLog
> /// </summary>
> static DebugLog()
> {
> XmlConfigurator.Configure();
> }
> /// <summary>
> /// Logs the Info
> /// </summary>
> /// <param name="loginfo"></param>
> public void DoLogging(string loginfo)
> {
> if (logger.IsDebugEnabled)
> {
> logger.Debug(loginfo);
> }
> }
> }
> public class InfoLog
> {
> private static readonly ILog logger =
> LogManager.GetLogger(typeof(InfoLog));
> /// <summary>
> /// InfoLog Constructor
> /// </summary>
> static InfoLog()
> {
> XmlConfigurator.Configure();
> }
> /// <summary>
> /// Logs the Info Log
> /// </summary>
> /// <param name="logInfo"></param>
> public void DoLogging(string logInfo)
> {
> if (logger.IsInfoEnabled)
> {
> logger.Info(logInfo);
> }
> }
> }
> public class ErrorLog
> {
> private static readonly ILog logger =
> LogManager.GetLogger(typeof(ErrorLog));
> /// <summary>
> /// ErrorLog Constructor
> /// </summary>
> static ErrorLog()
> {
> XmlConfigurator.Configure();
> }
> /// <summary>
> /// Logs teh Errror
> /// </summary>
> /// <param name="logError"></param>
> public void DoLogging(string logError)
> {
> if (logger.IsInfoEnabled)
> {
> logger.Error(logError);
> }
> }
> }
> }
> --- CODE END ----
> Many Thanks,
> Amit.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira