473,387 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

log4net logger.File property. Error: "The given path's format is not supported."

Ravi L
12
I need to configure log4net programmatically. I got the code for this from the net which lots of users happen are using. But when I get an error saying "The given path's format is not supported." at logger.ActivateOptions. the code is reproduced below:

Expand|Select|Wrap|Line Numbers
  1. public class Logger
  2. {
  3.         private PatternLayout _layout = new PatternLayout();
  4.         private const string LOG_PATTERN = "%d [%t] %-5p %m%n";
  5.  
  6.         public string DefaultPattern
  7.         {
  8.                 get { return LOG_PATTERN; }
  9.         }
  10.  
  11.     public Logger()
  12.     {
  13.         _layout.ConversionPattern = DefaultPattern;
  14.         _layout.ActivateOptions();
  15.     }
  16.  
  17.     public PatternLayout DefaultLayout
  18.     {
  19.         get { return _layout; }
  20.     }
  21.  
  22.     public void AddAppender(IAppender appender)
  23.     {
  24.         Hierarchy hierarchy = 
  25.                 (Hierarchy)LogManager.GetRepository();
  26.  
  27.         hierarchy.Root.AddAppender(appender);
  28.     }
  29.  
  30.     static Logger()
  31.     {
  32.         try
  33.         {
  34.             Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();            
  35.             PatternLayout patternLayout = new PatternLayout();
  36.  
  37.  
  38.             RollingFileAppender roller = new RollingFileAppender();            
  39.             roller.AppendToFile = true;
  40.             roller.RollingStyle = RollingFileAppender.RollingMode.Size;
  41.             roller.MaxSizeRollBackups = 4;
  42.             roller.MaximumFileSize = "10000KB";
  43.             roller.StaticLogFileName = true;            
  44.             roller.File = "c:\\errorlog\\dnservices.log";
  45.  
  46.             patternLayout.ConversionPattern = LOG_PATTERN;
  47.             patternLayout.ActivateOptions();
  48.             roller.Layout = patternLayout;
  49.             roller.ActivateOptions();
  50.             hierarchy.Root.AddAppender(roller);
  51.  
  52.             hierarchy.Root.Level = Level.All;
  53.             hierarchy.Configured = true;
  54.         }
  55.         catch (Exception)
  56.         {            
  57.             throw;
  58.         }
  59.     }
  60.  
  61.     public static ILog Create()
  62.     {
  63.         return LogManager.GetLogger("Logger");
  64.     }
  65. }
I am using Visual Studio 2010 for development. Will this make any difference. the log4net version is 1.2.0.10. Have spent a lot of time on this to end up with this error. Any help would be appreciated.

Thank you.

Ravi
May 9 '12 #1
0 1770

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: muesliflakes | last post by:
I have tried to build an Installation Project for to different applications. Both are simple. Steps Taken: * Add New Setup Project to the solution * Set the project out to the application...
0
by: Keith Smith | last post by:
When I create a setup file (MSI) for my app, I get the following error when I try to run the MSI file... The folder path '.' contains an invalid character Does anyone know a solution to this? ...
5
by: Stan | last post by:
When I create a Web project and then try to add the files to it (Add Existing Item), I get this error message "The folder http://localhost/FinWeb is no longer availabe" In fact the folder and...
0
by: xz | last post by:
I just installed Visual web dev. 2005 beta 1. I've never used the lite SQL server 2005 database, so I decided to try it out. From the Visual web dev. I selected 'create new sql server database' ...
0
by: Rob Meade | last post by:
Hi all, I've written a small app which firstly reads in from an xml config file to set some start parameters. once this is done, it takes the supplied path from the config file, iterates...
0
by: jabber | last post by:
Hi, I am trying to create databases in a specific diretcory on my windows server. The command I am using is :- db2 create db mhi on c:\mhi with 'mark test' Error received is :- SQL1052N The...
0
by: Bill Fuller | last post by:
I downloaded the sample code for the Windows Workflow article in the December 2006 edition of MSDN magazine. However, when I attempted to start the solution, I get an error for each of the three...
0
by: Darrel | last post by:
I get this error when trying to run a file upload function on my client's server. It works fine on my local server. I can also create a directory via my code, but not upload a file. I'm...
2
by: Darrel | last post by:
(I posted this previously in the wrong NG.) I get this error when trying to run a file upload function on my client's server. It works fine on my local server. I can also create a directory...
2
by: =?Utf-8?B?QW5keSBD?= | last post by:
Hi, I'm trying to load some XML into a dataset with C# but I have an issue with the schema. I'm using exactly the same code to successfully load other XML. The only difference is in the XML...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.