RE: Website content errors/ambiguity

2007-04-27 Thread Nicko Cadell
Thanks for the heads up. I have updated the site.

 

The new text for the Logging Context section is:

 

log4net can be used to collect logging context data in a way that is
transparent 

to the developer at the point of logging. The GlobalContext and the 

ThreadContext allow the application to store contextual data that is

attached to logging messages. For instance, in a web service, 

once the caller is authenticated the username of the caller could be 

stored in a ThreadContext property. This property would then be
automatically 

logged as part of each subsequent logging message made from the same
thread.

 

Thanks,

Nicko

 


nicko cadell [EMAIL PROTECTED]
+44 (0)20 7025 0933
http://www.neoworks.com/
software consultancy.solutions.support 

From: Lachlan McCabe [mailto:[EMAIL PROTECTED] 
Sent: 27 April 2007 01:19
To: log4net-user@logging.apache.org
Subject: Website content errors/ambiguity

 


Hi,


I've found this comment on your website that is confusing to me.


 


On http://logging.apache.org/log4net/release/features.html#context, the
text is can makes it contradictory, which one is it?


 


Logging Context


log4net can collect logging context data in a way that is transparent to
the developer at the point of logging. The GlobalContext and the
ThreadContext allow the application to capture contextual data and for
it to be attached to logging messages. For instance, in a web service,
once the caller is authenticated the username of the caller is can be
stored in a ThreadContext property. This property is then automatically
logged as part of each logging message.


 


Also on http://logging.apache.org/log4net/release/faq.html, the
Framework Support link does not work.

 


What are the prerequisites for log4net?


log4net runs on many different frameworks and each framework has its own
requirements. As a rule of thumb you will need an ECMA-335 compliant CLI
runtime, for example, the Microsoft .NET runtime 1.0 (1.0.3705) or 1.1
(1.1.4322). 

Not all frameworks are created equal and some features have been
excluded from some of the builds. See the Framework Support
http://logging.apache.org/log4net/framework-support.html  document for
more information.

 

Thanks


Lachlan



RE: System.Trace.Diagnostics to log4net

2007-03-21 Thread Nicko Cadell
I don't think that there is a standard trace listener for routing events
into log4net, but is should be simple to knock one up. The issues are
that from the TraceListener API you can log without specifying a
category, and the listener itself does not know the level you are
logging at. But apart from that you can do something like:


using System.Diagnostics;

namespace TestConsoleApp
{
public class Log4NetListener : TraceListener
{
public override bool IsThreadSafe
{
get { return true; }
}

public override void Write(string message)
{
Write((object)message, null);
}

public override void Write(object o)
{
Write(o, null);
}

public override void Write(object o, string category)
{
// Come up with a useful default logger name
if (category == null || category.Length == 0)
{
category = Log4NetListener;
}
log4net.LogManager.GetLogger(category).Info(o);
}

public override void Write(string message, string
category)
{
Write((object)message, category);
}

public override void WriteLine(string message)
{
Write(message);
}

public override void WriteLine(object o)
{
Write(o);
}

public override void WriteLine(object o, string
category)
{
Write(o, category);
}

public override void WriteLine(string message, string
category)
{
Write(message, category);
}
}
}

Cheers.

 -Original Message-
 From: Widerberg Marcus [mailto:[EMAIL PROTECTED] 
 Sent: 21 March 2007 14:06
 To: log4net-user@logging.apache.org
 Subject: System.Trace.Diagnostics to log4net
 
 Hello,
 
 I would like to get diagnostics messages (for different wcf 
 services) routed to log4net and then to the log4net appenders.
 
 Is there a standard way to do this? Basically, I need a 
 tracelistener for the system diagnostics trace system that 
 sends the messages on to log4net. A Log4NetListener.
 
 Any help appreciated!
 
 Best regards,
 
 /mawi
 


RE: Log4Net configuration

2007-02-12 Thread Nicko Cadell
You can change the display name for the levels in the log4net config
file:

log4net
  level
name value=FATAL /
displayName value=ALERT /
  /level

  ...
/log4net

Specify the name of the existing level and the display name to use in
the appender output.

Cheers,
Nicko


nicko cadell [EMAIL PROTECTED]
+44 (0)20 7025 0933
http://www.neoworks.com/
software consultancy.solutions.support 

Neoworks Limited is a company registered in England at 2-3 North Mews,
London, WC1N 2JP with company number 1001737.
 

 -Original Message-
 From: Laxmilal Menaria [mailto:[EMAIL PROTECTED] 
 Sent: 30 January 2007 10:24
 To: log4net-user@logging.apache.org
 Subject: Log4Net configuration
 
 Hi,
 
 I am using Log4Net for My website. that is good logging tool. 
 I am using rollingfile Appender, with info, debug, warn ans 
 fatel level.. but when use that level the log file have 
 llevels WARN, FATAL, INFO, and DEBUG, I wants instead of 
 these words custom words for that.. so anyone tell me about, 
 is it possible of How ?
 
 Thanks in Advance,
 Laxmilal Menaria
 
 _
 Latest from the world of gadgets and gizmos 
 http://content.msn.co.in/Technology/Default.htm
 
 


RE: what's wrong with my application?

2006-10-28 Thread Nicko Cadell
The FileAppender needs a layout object to format the log message for
output.

Before f.ActivateOptions(); add the following:

f.Layout = new log4net.Layout.PatternLayout();   // use
DefaultConversionPattern
((log4net.Core.IOptionHandler)f.Layout).ActivateOptions(); 

Cheers,
Nicko

 -Original Message-
 From: Ori - Gmail [mailto:[EMAIL PROTECTED] 
 Sent: 17 October 2006 09:49
 To: log4net-user@logging.apache.org
 Subject: what's wrong with my application?
 
 I wrote a very simple c# application to try writing to log 
 file, and it doesn't work. The log stays empty.
 
 Can someone please tell me why?
 
  
 
 The application code:
 
  
 
 using System;
 
 using System.Collections.Generic;
 
 using System.ComponentModel;
 
 using System.Data;
 
 using System.Drawing;
 
 using System.Text;
 
 using System.Windows.Forms;
 
 using log4net;
 
 using log4net.Appender;
 
  
 
 namespace Log4netTry
 
 {
 
 public partial class Form1 : Form
 
 {
 
 static ILog log;
 
 public Form1()
 
 {
 
 InitializeComponent();
 
 FileAppender f = new FileAppender();
 
 f.ImmediateFlush = true;
 
 f.File = text.log;
 
 f.ActivateOptions();
 
 log4net.Config.BasicConfigurator.Configure(f);
 
 log = LogManager.GetLogger(MyLog);  
   
 
 }
 
  
 
 private void Form1_Load(object sender, EventArgs e)
 
 {
 
 log.Error(Moony);
 
 log.Debug(ddsdsds);
 
 }
 
 }
 
 }
 
 


RE: Application Config File

2006-10-28 Thread Nicko Cadell
Hoschie,

That's what Microsoft decided in Visual Studio. Presumably they think
that C++ developers like to be in control of everything, so they do
nothing automatically. Note that the C# compiler doesn't copy the
App.config file, it is Visual Studio that does it.

Nicko

 -Original Message-
 From: Hans Schlegel [mailto:[EMAIL PROTECTED] 
 Sent: 11 October 2006 06:20
 To: log4net-user@logging.apache.org
 Subject: Application Config File
 
 Hey,
 
 I am using VS.NET 2003 Framework 1.1 with Managed C++ and had 
 some problems with the application configuration file which I 
 wanted to use to configure log4net. The build process never 
 created the applicationname.exe.config file from the app.config.
 
 As I learned from 
 http://www.codeguru.com/cpp/cpp/cpp_managed/asp/article.php/c4873/
 this is only automatically done for VB and C# so I added the 
 Post-Build step to copy the file to the right place.
 
 Before figured this out I tried the ConsoleApp example from 
 the cpp-examples which is part of the examples of the 
 log4net release. Here the applicationname.exe.config was 
 allways created without the Post-Build step. 
 
 I couldnt figure out what they make different but I'm curious
 
 Anybody has an idea?
 
 Thanks for reading...
 
 Hoschie
 
 
 
 
 
 
 Keine Lust auf Tippen? Rufen Sie Ihre Freunde einfach an.
 Yahoo! Messenger. Jetzt installieren 
 http://de.rd.yahoo.com/evt=39060/*http://de.messenger.yahoo.com . 
 


RE: Turn off logging for a specific event only

2006-10-28 Thread Nicko Cadell
What about using:

// Disable logging
LogManager.GetRepository().Threshold = Level.Off; 

// Do stuff

// Enable logging
LogManager.GetRepository().Threshold = Level.All;


Cheers,
Nicko

 -Original Message-
 From: Ramaa Davanagere [mailto:[EMAIL PROTECTED] 
 Sent: 27 September 2006 12:38
 To: 'Log4NET User'
 Subject: RE: Turn off logging for a specific event only
 
  
 
 Below is the structure of my code. In my constructor, I load 
 my configuration file and configure my log4net logger.
 
  
 
 myFunction() method gets called from the Main() method. As 
 you can see, when entering the myFunction() method, I want to 
 set the log level to OFF and then reset it to DEBUG while 
 exiting the function. The myFunction() methods calls several 
 other components and methods (for eg: a,b, c, etc) to do 
 stuff and hence passing the Boolean variable to this method 
 will not work. Also, having an separate appender will not 
 work in my scenario, since the methods a, b and c will be 
 used in various other places as well.
 
  
 
 public myConstructor()
 
 {
 
 if (logconfigpath == null)
 
 {
 
 logconfigpath = 
 System.AppDomain.CurrentDomain.BaseDirectory;
 
 logconfigpath += 
 System.AppDomain.CurrentDomain.RelativeSearchPath;
 
 
 log4net.Config.XmlConfigurator.Configure(new 
 System.IO.FileInfo(Path.GetFullPath(logconfigpath) + 
 Path.DirectorySeparatorChar.ToString() + myconfigfile.xml));
 
 }
 
 }
 
  
 
 public void Main(XmlElement oParameter1, string sParameter2, 
 string sParameter3, string sParameter4)
 
 {
 
 
 logger.Info(System.Reflection.MethodBase.GetCurrentMethod() + 
 : Entering.);
 
 
 
 //do my stuff here.
 
 
 
 String sResult = myFunction (oParameter1, sParameter2);
 
 
 
 
 logger.Info(System.Reflection.MethodBase.GetCurrentMethod() + 
 : Leaving.);
 
 }
 
  
 
 private string myFunction(XmlElement oParameter1, string sParameter2)
 
 {
 
 //turn off logging here...I would like to set the 
 loglevel to OFF
 
 
 
 //do my stuff here.
 
 
 
 //turn on the logging .I would like to reset the 
 loglevel to DEBUG
 
  
 
 }
 
  
 
 After looking around on the internet, I found this code
 
  
 
 log4net.Repository.Hierarchy.Logger logger2 = 
 (log4net.Repository.Hierarchy.Logger)log4net.LogManager.GetLog
 ger(myappendername).Logger);
 
 logger2.Level = logger2.Repository.LevelMap[OFF];
 
  
 
 But this is not working as expected.  Log messages are still 
 being writing to my log file, even though the level is set to 
 OFF. Obviously, I'm missing something here. 
 
  
 
 Please help
 
  
 
 Thank you
 
  
 
 -Ramaa
 
  
 
 -Original Message-
 From: Ron Grabowski [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, September 26, 2006 7:04 PM
 To: Log4NET User
 Subject: Re: Turn off logging for a specific event only
 
  
 
 Will this work?
 
  
 
 private int calculateBigNumber(bool loggingEnabled)
 
  
 
 {
 
  
 
  if (loggingEnabled  log.IsDebugEnabled)
 
  
 
  {
 
  
 
   log.Debug(Entering method);
 
  
 
  }
 
  
 
  int result = 0;
 
  
 
  for (int i=0;i100;i++)
 
  
 
  {
 
  
 
   result += i;
 
  
 
  }
 
  
 
  if (loggingEnabled  log.IsDebugEnabled)
 
  
 
  {
 
  
 
   log.Debug(Leaving method);
 
  
 
  }
 
  
 
  return result;
 
  
 
 }
 
  
 
  
 
  
 
 - Original Message 
 
  
 
 From: Ramaa Davanagere [EMAIL PROTECTED]
 
  
 
 To: log4net-user@logging.apache.org 
 log4net-user@logging.apache.org
 
  
 
 Sent: Tuesday, September 26, 2006 2:28:19 PM
 
  
 
 Subject: Turn off logging for a specific event only
 
  
 
  
 
  
 
!--  _filtered {font-family:Comic Sans MS; 
 panose-1:3 15 7 2 3 3 2 2 2 4;} /* Style Definitions */  
 p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; 
 margin-bottom:.0001pt; font-size:12.0pt; font-family:Times 
 New Roman;} a:link, span.MsoHyperlink  {color:blue; 
 text-decoration:underline;} a:visited, 
 span.MsoHyperlinkFollowed {color:purple; 
 text-decoration:underline;} span.EmailStyle17 
 {font-family:Comic Sans MS; color:windowtext; 
 font-weight:normal; font-style:normal; text-decoration:none 
 none;}  _filtered { margin:1.0in 1.25in 1.0in 1.25in;} 
 div.Section1  {} --
 
  
 
   Is it possible to turn off the logging for a specific 
 event? I would like to turn of the logging when the code hits 
 a particular method and reset the logging to its original 
 value which is DEBUG while exiting that method. Is it 
 possible to accomplish this? If so, please provide me some 
 sample code on how to achieve this. My code is in c#.net and 
 uses log4net version 1.2.10
 
  
 

 
  
 
   Please help 
 
  
 

 
  
 
   Thanks.
 
  
 

 
  
 
   -Ramaa
 
  
 
   
 
  
 
   
 
  
 
  
 
  
 
  
 
  
 
  
 
 


RE: [Fwd: mono and coloredconsoleappender]

2006-07-29 Thread Nicko Cadell
The ColouredConsoleAppender is not included in the mono build of
log4net. If you are using the mono-2.0 build of log4net it will not
contain the ColouredConsoleAppender.

Cheers,
Nicko

 -Original Message-
 From: Morten Andersen [mailto:[EMAIL PROTECTED] 
 Sent: 29 July 2006 09:02
 To: Log4NET User
 Subject: [Fwd: mono and coloredconsoleappender]
 
 Still a problem :)
 
  Original Message 
 Subject:  mono and coloredconsoleappender
 Date: Wed, 26 Jul 2006 11:21:11 +0200
 From: Morten Andersen [EMAIL PROTECTED]
 Reply-To: Log4NET User log4net-user@logging.apache.org
 To:   Log4NET User log4net-user@logging.apache.org
 
 
 
 Hi,
 
 I am trying to compile my projects into mono and I have one 
 small problem.
 
 error CS0234: The type or namespace name 
 `ColoredConsoleAppender' does not exist in the namespace 
 `log4net.Appender'. Are you missing an assembly reference?
 Compilation failed: 1 error(s), 0 warnings
 
 If I switch to ConsoleAppender there is no errors.
 
 I am using the mono-2.0 dll in the log4net package.
 
 - Morten
 
 
 


RE: Error: Unable to find the specified file (RollingLogFileAppender)

2006-07-18 Thread Nicko Cadell
Pablo,

Which version of log4net are you using?

Cheers,
Nicko

 -Original Message-
 From: Pablo Rodrigo [mailto:[EMAIL PROTECTED] 
 Sent: 18 July 2006 12:28
 To: log4net-user@logging.apache.org
 Subject: Error: Unable to find the specified file 
 (RollingLogFileAppender)
 
 Hi,
 After a long time processing, the log4net fail on writing the 
 log file.
 Here it is the error:
  
 Exception Information
 System.IO.FileNotFoundException: Unable to find the specified file.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.__Error.WinIOError()
at System.IO.FileInfo.MoveTo (String destFileName)
at log4net.Appender.RollingFileAppender.RollFile(String 
 from, String to)
at log4net.Appender.RollingFileAppender.RollOverSize()
at 
 log4net.Appender.RollingFileAppender.SubAppend(LoggingEvent 
 loggingEvent) 
at log4net.Appender.TextWriterAppender.Append(LoggingEvent 
 loggingEvent)
at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent 
 loggingEvent)
at 
 log4net.helpers.AppenderAttachedImpl.AppendLoopOnAppenders 
 (LoggingEvent loggingEvent)
at log4net.Category.CallAppenders(LoggingEvent loggingEvent)
at log4net.Category.Log(Priority priority, Object message)
at log4net.Category.Info(Object message)
at 
 Cit.Projects.Globo.Agra.InfraStructure.Logger.Logger.logInfo 
 (String message) ...
 ...
  
 Configurations:
 log4net
  appender name=RollingLogFileAppender 
 type=log4net.Appender.RollingFileAppender,log4net
param name=File value=E:/agra2/log/loggerdecae.log / 
param name=AppendToFile value=true /
param name=MaxSizeRollBackups value=20 /
param name=MaximumFileSize value=100MB / 
param name=RollingStyle value=Size /
param name=StaticLogFileName value=true /
layout type=log4net.Layout.PatternLayout ,log4net
 param name=ConversionPattern value=[lt;%-5pgt; 
 %d{dd/MM/ HH:mm:ss:fff}]: %m%n /
/layout
  /appender
  root
   priority value=DEBUG /
  /root
  category name=Cit.Projects.Globo.Agra
 appender-ref ref=RollingLogFileAppender /  /category
   /log4net
  
 Anyone pass through the same problem ?
  
 Thanks
 


RE: Error: Unable to find the specified file (RollingLogFileAppender)

2006-07-18 Thread Nicko Cadell
Pablo,

Many issues have been fixed since version 1.1.1.

Please upgrade to the latest version 1.2.10. You can download this from
http://logging.apache.org/log4net/downloads.html

Cheers,
Nicko 

 -Original Message-
 From: Pablo Rodrigo [mailto:[EMAIL PROTECTED] 
 Sent: 18 July 2006 12:55
 To: Log4NET User
 Subject: Re: Error: Unable to find the specified file 
 (RollingLogFileAppender)
 
 Loocking the .dll file, shows me 1.1.1.33753
 
 
 On 7/18/06, Nicko Cadell [EMAIL PROTECTED] wrote: 
 
   Pablo,
   
   Which version of log4net are you using?
   
   Cheers,
   Nicko
   
-Original Message- 
From: Pablo Rodrigo [mailto:[EMAIL PROTECTED]
Sent: 18 July 2006 12:28
To: log4net-user@logging.apache.org 
Subject: Error: Unable to find the specified file
(RollingLogFileAppender)
   
Hi,
After a long time processing, the log4net fail on writing the
log file.
Here it is the error: 
   
Exception Information
System.IO.FileNotFoundException: Unable to find the 
 specified file.
   at System.IO.__Error.WinIOError(Int32 errorCode, 
 String str)
   at System.IO.__Error.WinIOError ()
   at System.IO.FileInfo.MoveTo (String destFileName)
   at log4net.Appender.RollingFileAppender.RollFile(String
from, String to)
   at log4net.Appender.RollingFileAppender.RollOverSize() 
   at
log4net.Appender.RollingFileAppender.SubAppend(LoggingEvent
loggingEvent)
   at log4net.Appender.TextWriterAppender.Append(LoggingEvent
loggingEvent)
   at log4net.Appender.AppenderSkeleton.DoAppend (LoggingEvent
loggingEvent)
   at
log4net.helpers.AppenderAttachedImpl.AppendLoopOnAppenders
(LoggingEvent loggingEvent)
   at log4net.Category.CallAppenders(LoggingEvent 
 loggingEvent) 
   at log4net.Category.Log(Priority priority, Object message)
   at log4net.Category.Info(Object message)
   at
Cit.Projects.Globo.Agra.InfraStructure.Logger.Logger.logInfo
(String message) ... 
...
   
Configurations:
log4net
 appender name=RollingLogFileAppender
type=log4net.Appender.RollingFileAppender,log4net
   param name=File 
 value=E:/agra2/log/loggerdecae.log / 
   param name=AppendToFile value=true /
   param name=MaxSizeRollBackups value=20 /
   param name=MaximumFileSize value=100MB / 
   param name=RollingStyle value=Size /
   param name=StaticLogFileName value=true /
   layout type=log4net.Layout.PatternLayout ,log4net
param name=ConversionPattern value=[lt;%-5pgt;
%d{dd/MM/ HH:mm:ss:fff}]: %m%n /
   /layout
 /appender 
 root
  priority value=DEBUG /
 /root
 category name=Cit.Projects.Globo.Agra
appender-ref ref=RollingLogFileAppender /  
 /category 
  /log4net
   
Anyone pass through the same problem ?
   
Thanks
   
   
 
 
 


RE: Why each message printed 2 times?

2006-07-14 Thread Nicko Cadell
If you mean that you have 2 separate processes that are both logging the
same data to the same file, then you would expect the same messages to
be logged, both processes are doing the work, you would expect to see
the messages from both.

You might want to configure the layout to include the process id of the
process that is logging so that you can differentiate between your 2
processes.

Setup the process id in the GlobalContext when you initialise logging:

log4net.GlobalContext.Properties[processId] =
System.Diagnostics.Process.GetCurrentProcess().Id;

Then add %property{processId} to your layout pattern.

If this isn't your scenario could you explain a little more your
architecture and the relationship between the appenders and the 2
processes calling the initialisation code.

 Also standard questions: log4net version, .net runtime 
 version, application type (ASP.NET/EXE)

Answering these might also be helpful.

Cheers,

Nicko

 -Original Message-
 From: Bonio Lopez [mailto:[EMAIL PROTECTED] 
 Sent: 14 July 2006 08:13
 To: 'Log4NET User'
 Subject: RE: Why each message printed 2 times?
 
 Hi Niko,
 I understand now what is going on. The initialization code is 
 called from 2 processes and appender writes in the same file. 
 Is it possible somehow to attach to the same appender from 
 other process? Is there some shared
 log4net appender object, which can be acquired from other 
 process, when one process already initialized it?
 i.e.
 If XXX.already_initialized then attach else initialize.
 
 Thank you very much
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Mittwoch, 12. Juli 2006 10:34
 To: Log4NET User
 Subject: RE: Why each message printed 2 times?
 
 This is usually caused by having 2 appenders writing to the 
 same output.
 These could be both attached to the same logger or to 
 different loggers (i.e. a logger and the root logger).
 
 Can you post your complete configuration code (looks like you 
 are doing it in code rather than via an xml file). Or a 
 simplified version of your code that demonstrates this (just 
 the config code and a single log call would do). Are you 
 calling your config code only once or multiple times?
 
 Have you enabled log4net's internal debugging?
 http://logging.apache.org/log4net/release/faq.html#internalDebug
 
 Also standard questions: log4net version, .net runtime 
 version, application type (ASP.NET/EXE)
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Bonio Lopez [mailto:[EMAIL PROTECTED]
  Sent: 11 July 2006 17:51
  To: 'Log4NET User'
  Subject: Why each message printed 2 times?
  
  Dear all,
  With minimal lock each message is printed into a log file 2 times. 
  i.e.
  [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing
  [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing With 
 exclusive 
  lock works as expected.
  Any ideas why?
  
  
  
  m_LockingModel = new FileAppender.MinimalLock(); 
 m_FileAppender = new 
  FileAppender(); m_FileAppender.Layout = new 
  log4net.Layout.PatternLayout([%date{dd MMM  
 HH:mm:ss,fff}] %level 
  %logger  - %message%newline); m_FileAppender.File = path_to_log + 
  @\ + m_logger_file_name; m_FileAppender.LockingModel = 
  m_LockingModel; m_FileAppender.ImmediateFlush = true; 
  m_FileAppender.AppendToFile = true;
  
  
 
 


RE: Why each message printed 2 times?

2006-07-14 Thread Nicko Cadell
If you have 2 applications that each create a single appender in their
process then the appenders will be completely independent. When you say
that the 2 applications call the same init code (for the appender) do
you mean that the code is duplicated in both applications or in a class
library.

If you have 2 appenders, each in a separate application, then they will
only log the log events generated within their application. They will be
independent of the other application. The only think that they have in
common is that they name of the file they are writing to is the same.

If you are writing to a single log file from multiple applications I
strongly suggest that you include in your log messages an identifier for
the application that is source of the log message. You can do that by
adding the processId as per my previous message.

Do you have to run both of your applications at the same time? If you
run just 1 do you still get duplicate log messages?

Nicko

 -Original Message-
 From: Bonio Lopez [mailto:[EMAIL PROTECTED] 
 Sent: 14 July 2006 11:49
 To: 'Log4NET User'
 Subject: RE: Why each message printed 2 times?
 
 Hi Niko,
 snip---
 If you mean that you have 2 separate processes that are both 
 logging the same data to the same file, then you would expect 
 the same messages to be logged, both processes are doing the 
 work, you would expect to see the messages from both.
 snip---
 
 You misunderstand me. I have 2 applications which need to log 
 messages (not the same messages) into the same init file. So 
 two processes call the same init code (which I have posted). 
 So there seems to be 2 appenders with the same 
 initialization. And each of those 2 appenders loggs. 
 Therefore I suppose each message is logged 2 times. It seems 
 that I have 2 appenders, getting every message. Am I right? 
 How can I solve that?
 
 I use .NET1.1, log4net 1.2.9, application type: .NET (not asp)
 
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Freitag, 14. Juli 2006 11:31
 To: Log4NET User
 Subject: RE: Why each message printed 2 times?
 
 If you mean that you have 2 separate processes that are both 
 logging the same data to the same file, then you would expect 
 the same messages to be logged, both processes are doing the 
 work, you would expect to see the messages from both.
 
 You might want to configure the layout to include the process 
 id of the process that is logging so that you can 
 differentiate between your 2 processes.
 
 Setup the process id in the GlobalContext when you initialise logging:
 
 log4net.GlobalContext.Properties[processId] = 
 System.Diagnostics.Process.GetCurrentProcess().Id;
 
 Then add %property{processId} to your layout pattern.
 
 If this isn't your scenario could you explain a little more 
 your architecture and the relationship between the appenders 
 and the 2 processes calling the initialisation code.
 
  Also standard questions: log4net version, .net runtime version, 
  application type (ASP.NET/EXE)
 
 Answering these might also be helpful.
 
 Cheers,
 
 Nicko
 
  -Original Message-
  From: Bonio Lopez [mailto:[EMAIL PROTECTED]
  Sent: 14 July 2006 08:13
  To: 'Log4NET User'
  Subject: RE: Why each message printed 2 times?
  
  Hi Niko,
  I understand now what is going on. The initialization code 
 is called 
  from 2 processes and appender writes in the same file.
  Is it possible somehow to attach to the same appender from other 
  process? Is there some shared
  log4net appender object, which can be acquired from other process, 
  when one process already initialized it?
  i.e.
  If XXX.already_initialized then attach else initialize.
  
  Thank you very much
  
  -Original Message-
  From: Nicko Cadell [mailto:[EMAIL PROTECTED]
  Sent: Mittwoch, 12. Juli 2006 10:34
  To: Log4NET User
  Subject: RE: Why each message printed 2 times?
  
  This is usually caused by having 2 appenders writing to the same 
  output.
  These could be both attached to the same logger or to different 
  loggers (i.e. a logger and the root logger).
  
  Can you post your complete configuration code (looks like you are 
  doing it in code rather than via an xml file). Or a 
 simplified version 
  of your code that demonstrates this (just the config code 
 and a single 
  log call would do). Are you calling your config code only once or 
  multiple times?
  
  Have you enabled log4net's internal debugging?
  http://logging.apache.org/log4net/release/faq.html#internalDebug
  
  Also standard questions: log4net version, .net runtime version, 
  application type (ASP.NET/EXE)
  
  Cheers,
  Nicko
  
   -Original Message-
   From: Bonio Lopez [mailto:[EMAIL PROTECTED]
   Sent: 11 July 2006 17:51
   To: 'Log4NET User'
   Subject: Why each message printed 2 times?
   
   Dear all,
   With minimal lock each message is printed into a log file 
 2 times. 
   i.e.
   [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing
   [11 Jul

RE: Appenders and AppDomains

2006-07-14 Thread Nicko Cadell
AppDomains are logical isolation units akin to lightweight processes.
log4net cannot exist outside an AppDomain because nothing can exist
outside an AppDomain. log4net must be configured in each AppDomain, and
it know nothing about the appenders or configuration in the other
AppDomains. Each AppDomain will have its own logger hierarchy and root
logger.

It is quite a challenge to find all the AppDomains in the process and
hook them up.

There are 2 different approaches that I can think of:

1) Create a MarshalByRef appender implementation, i.e. a class that
extends MarshalByRefObject and implements the IAppender interface. This
could just be a simple wrapper that forwards the call to another
IAppender, allowing you to reuse the existing appenders. 
This appender and the MarshalByRef appender wrapper would need to be
created in only 1 AppDomain. You would then need to get a reference to
this wrapper via remoting into each of the other AppDomains and then
attach that appender reference to the root logger in that AppDomain.

2) The other approach is similar in that it still requires remoting, but
rather than marshalling the appender across and attaching it to the
logger hierarchy in all the AppDomains, the events logged in the
AppDomains are sent via remoting to a single published listener which
re-logs the event it its AppDomain. This allows the logging events to be
centralised in a single AppDomain, but they can still be logged in their
own AppDomains.
To do this you will need to use the RemotingAppender in each of your
AppDomains. The RemotingAppender will sent the LoggingEvent via .NET
remoting to a published listener. The RemoteLoggingServerPlugin is a
built-in way of publishing a listener. See the Remoting examples in the
log4net download, examples\net\1.0\Remoting. In your case rather than
running separate processes, one of your AppDomains will be the server
(and receive logging events) and all the other AppDomains will be the
clients.

Cheers,
Nicko

 -Original Message-
 From: Morten Andersen [mailto:[EMAIL PROTECTED] 
 Sent: 14 July 2006 14:30
 To: Log4NET User
 Subject: Appenders and AppDomains
 
 Hi
 
 Is it possible to have one appender for all app domains in a process? 
 Each app domain has its own appender, but I also want a 
 global appender for all domains.
 
 - Morten
 
 


RE: Why each message printed 2 times?

2006-07-12 Thread Nicko Cadell
This is usually caused by having 2 appenders writing to the same output.
These could be both attached to the same logger or to different loggers
(i.e. a logger and the root logger).

Can you post your complete configuration code (looks like you are doing
it in code rather than via an xml file). Or a simplified version of your
code that demonstrates this (just the config code and a single log call
would do). Are you calling your config code only once or multiple times?

Have you enabled log4net's internal debugging?
http://logging.apache.org/log4net/release/faq.html#internalDebug

Also standard questions: log4net version, .net runtime version,
application type (ASP.NET/EXE)

Cheers,
Nicko

 -Original Message-
 From: Bonio Lopez [mailto:[EMAIL PROTECTED] 
 Sent: 11 July 2006 17:51
 To: 'Log4NET User'
 Subject: Why each message printed 2 times?
 
 Dear all,
 With minimal lock each message is printed into a log file 2 times. 
 i.e.
 [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing
 [11 Jul 2006 18:43:10,663] DEBUG Log1  - pi is nothing With 
 exclusive lock works as expected.
 Any ideas why?
 
 
 
 m_LockingModel = new FileAppender.MinimalLock(); 
 m_FileAppender = new FileAppender(); m_FileAppender.Layout = 
 new log4net.Layout.PatternLayout([%date{dd MMM  
 HH:mm:ss,fff}] %level %logger  - %message%newline); 
 m_FileAppender.File = path_to_log + @\ + 
 m_logger_file_name; m_FileAppender.LockingModel = 
 m_LockingModel; m_FileAppender.ImmediateFlush = true; 
 m_FileAppender.AppendToFile = true;
 
 


RE: ASP .NET 2.0 Security error - Config problems - Any ideas?

2006-07-10 Thread Nicko Cadell
Daniel,

If I run with your config I get the following message in the Debug
Output window in VisualStudio:


log4net:ERROR XmlHierarchyConfigurator: Could not create Appender
[FileAppender] of type [log4net.Appender.FileAppender]. Reported error
follows.
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.
   at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark stackMark, Boolean isPermSet)
   at System.Security.CodeAccessPermission.Demand()
   at System.IO.Path.GetFullPath(String path)
   at log4net.Util.SystemInfo.ConvertToFullPath(String path)
   at log4net.Appender.FileAppender.ConvertToFullPath(String path)
   at log4net.Appender.FileAppender.ActivateOptions()
   at
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlE
lement appenderElement)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission
The Zone of the assembly that failed was:
MyComputer 


Looks like you don't have FileIOPermission in the Medium trust zone! If
this is the case on your deployment platform then you can't log to a
file!

Cheers,
Nicko


 -Original Message-
 From: Daniel Miller [mailto:[EMAIL PROTECTED] 
 Sent: 10 July 2006 13:47
 To: 'Log4NET User'
 Subject: RE: ASP .NET 2.0 Security error - Config problems - 
 Any ideas?
 
 Hi Nicko
 
 Still no luck. See the full web.config below. 
 With trust-level = Medium, it fails; without it, it succeeds.
 
 Any other ideas?
 
 Daniel
 
 ?xml version=1.0?
 configuration
   configSections
 section name=log4net
 type=log4net.Config.Log4NetConfigurationSectionHandler, log4net
 requirePermission=false /
   /configSections
   
   appSettings
 add key=CONTACT_EMAIL value=[EMAIL PROTECTED]/
 add key=SMTP_SERVER value=mail.my-domain.com/
   /appSettings
   connectionStrings/
   
   system.web
 trust level=Medium/
 customErrors mode=Off 
 defaultRedirect=~/home/maintenance.aspx
   error statusCode=404 redirect=~/home/page_not_found.aspx/
 /customErrors
 urlMappings enabled=true
   add url=~/default.aspx 
 mappedUrl=~/home/default.aspx/  
 /urlMappings
   compilation debug=true/
   authentication mode=Windows/
   /system.web
   log4net debug=false
 appender name=FileAppender 
 type=log4net.Appender.FileAppender
   param name=File value=..\logs\log-file.txt /
   param name=AppendToFile value=true /
   layout type=log4net.Layout.PatternLayout
 param name=ConversionPattern value=%d %-5p %c - %m%n /
   /layout
 /appender
 appender name=SmtpAppender
 type=log4net.Appender.SmtpAppender,log4net
   to value=[EMAIL PROTECTED] /
   from value=[EMAIL PROTECTED] /
   subject value=WOWO log message /
   smtpHost value=mail.my-domain.com /
   bufferSize value=1 /
   lossy value=false /
   threshold value=DEBUG /
   evaluator type=log4net.Core.LevelEvaluator,log4net
 threshold value=DEBUG /
   /evaluator
   layout type=log4net.Layout.PatternLayout,log4net
 conversionPattern value=%level :: %message %newlineLogger:
 %logger%newlineThread: %thread%newlineDate: %date%newline%newline /
   /layout
 /appender
 root
   appender-ref ref=SmtpAppender/
   appender-ref ref=FileAppender/
   level value=ALL/
 /root
   /log4net
   /configuration
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 10, 2006 3:06 PM
 To: Log4NET User
 Subject: RE: ASP .NET 2.0 Security error - Config problems - 
 Any ideas?
 
 Daniel,
 
 The 2 changes, adding the requirePermission=false and calling
 XmlConfigurator.Configure() from the Application_Start, do 
 fix the ConfigurationPermission exception that you were 
 seeing. Unfortunately you then run smack into another 
 SecurityException! This is caused by the LogicalThreadContext.
 
 You can work around this by not outputting any of the context 
 properties or stacks (i.e. %ndc or %property). Can you do 
 this to verify that this is the issue? (i.e. change your 
 appender's layout configuration to something like:)
 
 layout type=log4net.Layout.PatternLayout value=%date 
 [%thread] %-5level %logger - %message%newline /
 
 
 Fixing the SecurityException requires a code change to the 
 log4net library.
 
 http://issues.apache.org/jira/browse/LOG4NET-79?page=all
 http://svn.apache.org/viewvc?view=revrevision=420499
 
 If you need to log property values you will need to build 
 your own copy of the log4net library including the changes 
 above. Either get the latest source from SVN or use the 
 source from the 1.2.10 release and manually apply the above changes.
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Daniel Miller [mailto:[EMAIL PROTECTED]
  Sent: 10

RE: Logging Thread Context Properties

2006-07-09 Thread Nicko Cadell
I don't think this is a correct test case.
The ThreadContext.Properties[DateTimeTodayToString] is not set until
after the message is logged, therefore it is not in the context at the
time of the log message and therefore won't be in the appender's output.

Nicko

 -Original Message-
 From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
 Sent: 16 June 2006 05:21
 To: Log4NET User
 Subject: RE: Logging Thread Context Properties
 
 Here's a failing test case for the problem you described. The 
 StringAppender has a value of (null) when it should have 
 the string representation of today's date.
 
 A similiar test case that launches the thread via the ThreadPool:
 
  ThreadPool.QueueUserWorkItem(
   new WaitCallback(ExecuteBackgroundThreadPool), null);
 
 also fails.
 
 The TestThreadPropertiesPattern test from 
 log4net.Tests.Context.ThreadContextTest passes when the 
 property is added from the same thread.
 
 In my ASP.Net applications, I store the user's identification 
 information during Application_AuthenticateRequest in the
 ThreadContext(?) and all my appenders have access to it.
 
 I'll look around some more...
 
 [Test]
 public void TestBackgroundThreadContextProperty()
 {
  StringAppender stringAppender = new StringAppender();  
 stringAppender.Layout =
   new PatternLayout(%property{DateTimeTodayToString});
 
  ILoggerRepository rep =
   LogManager.CreateRepository(BackgroundThreadRepository);
 
  BasicConfigurator.Configure(rep, stringAppender);
 
  Thread thread = new Thread(new ThreadStart(ExecuteBackgroundThread));
  thread.Start();
 
  Thread.CurrentThread.Join(2000);
 }
 
 private void ExecuteBackgroundThread()
 {
  ILog log = LogManager.GetLogger(
   BackgroundThreadRepository,
   ExecuteBackgroundThread);
   
  log.Info(TestMessage);
 
  ThreadContext.Properties[DateTimeTodayToString] =
   DateTime.Today.ToString();
 
  Repository.Hierarchy.Hierarchy hierarchyLoggingRepository =
   (Repository.Hierarchy.Hierarchy)log.Logger.Repository;
   
  StringAppender stringAppender =
   (StringAppender)hierarchyLoggingRepository.Root.Appenders[0];
 
  Assert.AreEqual(DateTime.Today.ToString(),
 stringAppender.GetString());
 }
 
 --- Wayne Bradney [EMAIL PROTECTED] wrote:
 
  So, either I'm doing something so unbelievably stupid as to not 
  warrant a response, or this is a real problem, right?
  
   
  
  WMB
  
_
  
  From: Wayne Bradney [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, June 07, 2006 6:05 PM
  To: Log4NET User
  Subject: Logging Thread Context Properties
  
   
  
  I must be missing something here... I'm trying to setup a thread 
  property in my background thread such that my appender can 
 inspect the 
  property when an event is logged:
  
   
  
  The thread does this:
  
   
  
  log4net.ThreadContext.Properties[ThreadTaskDescription] = some
  string;
  
  log.Info(Some message);
  
   
  
   
  
  In the appender, when I look at the Properties property of the 
  LoggingEvent (Some message), it never has any properties at all.
  
   
  
  Am I doing this right?
  
   
  
  WMB
  
   
  
  
 
 


RE: Customize the exception output

2006-07-08 Thread Nicko Cadell
The PatternLayout uses the ObjectRenderer framework to convert the
Exception object into a string. The DefaultRenderer will just call the
ToString method on the Exception object. The ToString method can be
overridden by Exception subclasses.

If you want to use a custom rendering for Exception objects then you can
add your own custom exception renderer.
http://logging.apache.org/log4net/release/manual/configuration.html#rend
erers

The configuration can be specified in the log4net config file as:

renderer renderingClass=MyExceptionRenderer
renderedClass=System.Exception / 

And you need to build a class to do the rendering which implements the
log4net.ObjectRenderer.IObjectRenderer interface.

Cheers,
Nicko

 -Original Message-
 From: Sean Carlin [mailto:[EMAIL PROTECTED] 
 Sent: 21 June 2006 16:28
 To: log4net-user@logging.apache.org
 Subject: Customize the exception output
 
 Hi,
  
 I've had a request from the developers at my company to 
 modify the way in which log4net outputs exceptions to the 
 log.  This would need to take effect in my EventLogAppender 
 and AdoNetAppender.  Will I need to create my own custom 
 class similar to ExceptionLayout or a custom class similar to 
 ExceptionPatternConverter?  How can I specify this change to 
 the EventLogAppender?
 
 The request is to format the exception more like the way the 
 .NET Enterprise Library did in .NET 1.1.:
  
 1) Exception Information
 
 *
 
 Exception Type: X.WebApps.NewsRoom.WebControls.NewsSystemException
 
 Message: Could not retrieve a list of articles from the category
 
 Data: System.Collections.ListDictionaryInternal
 
 TargetSite: NULL
 
 HelpLink: NULL
 
 Source: NULL
 
 2) Exception Information
 
 *
 
 Exception Type: System.Exception
 
 Message: An error occurred while processing the required SQL 
 script: 
 D:\WebSites\X\WebAppsFolders\WebAppsCommonFiles\\scripts\core.config
 
 Data: System.Collections.ListDictionaryInternal
 
 TargetSite: Void ExecuteScripts(System.String, 
 System.String[], Boolean, Boolean)
 
 HelpLink: NULL
 
 Source: X.WebApps.CoreLibrary.X.X
 
 StackTrace Information
 
 *
 
 at X.WebApps.CoreSystem.ExecuteScripts(String path, String[] 
 scripts, Boolean trapExceptions, Boolean sendAppPath)
 
 at X.WebApps.CoreSystem.SystemInit()
 
 at X.WebApps.CoreSystem..ctor(String application)
 
 at 
 X.WebApps.NewsRoom.WebControls.NewsArticleDisplayer.GetNewsArt
 icleAndCategory(Category newsCategory, Article newsArticle)
 
  
 Here is a sample of what is being output by the default format:
  
 System.Exception: Testing application error handling from the 
 DevCenter/ApplicationErrorTest.aspx form. --- 
 System.ArrayTypeMismatchException: Oh my gosh some sort of 
 array mismatch occurred in this fake class! Error! Error!
 at RemoteNet.Zapenza.Utility.TestClass..ctor() in 
 C:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\Remot
 eNet.Zapenza.Utility\TestClass.cs:line 11 at 
 DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Objec
 t sender, EventArgs e) in 
 c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\Remot
 eNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:line 24
 --- End of inner exception stack trace --- at 
 DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Objec
 t sender, EventArgs e) in 
 c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\Remot
 eNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:lin
 e 28 at 
 System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at 
 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
  eventArgument) at 
 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEv
 entHandler.RaisePostBackEvent(String eventArgument) at 
 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler 
 sourceControl, String eventArgument) at 
 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 
 postData) at System.Web.UI.Page.ProcessRequestMain(Boolean 
 includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 


RE: new public key for 1.2.10?

2006-06-21 Thread Nicko Cadell
Bob,

It was not my intention to change the strong name key for the 1.2.10
release. Due to some misadventure the key has changed between version
1.2.9 and 1.2.10. This has the undesirable effect of preventing binding
redirects between these version working.

I am still investigating where my key management procedures broke down.
But I think that it is now essential for log4net to examine our policy
towards strong naming, especially as this is supposed to be an open
source project. Does the private key form an integral part of the
'source'? It is not required to build an identically functional
assembly, but it is required to build an identical binary replacement
assembly.

At this point in time I think it is not possible to remedy the situation
by producing official builds of the latest version with the old strong
name, however it may be possible to make an unofficial build with the
old key for compatibility purposes. I think this will be driven by our
internal discussion on future strong name key policy.

Regards,
Nicko


Nicko Cadell
log4net development
http://logging.apache.org/log4net

 -Original Message-
 From: Bob Hanson [mailto:[EMAIL PROTECTED] 
 Sent: 13 June 2006 17:13
 To: log4net-user@logging.apache.org
 Subject: new public key for 1.2.10?
 
 According to discussion at 
 http://forum.springframework.net/showthread.php?t=470, the 
 public key has changed from version 1.2.9 to 1.2.10.
 
 Was this by design? 
 
 


RE: how to get host name?

2006-05-29 Thread Nicko Cadell
The %property pattern was added in version 1.2.9. In older versions you
must use %P (capital P). If possible it is recommended that you upgrade
to the latest version of log4net. 

Cheers,
Nicko

 -Original Message-
 From: Cheng [mailto:[EMAIL PROTECTED] 
 Sent: 09 May 2006 19:02
 To: Log4NET User
 Subject: how to get host name?
 
 I am using AdoNetAppender. I want to log the name of the 
 machine that is running the application.
 
 I tried following but doesn't work:
 parameter
  parameterName value=@p_ServerName /  dbType 
 value=String /  size value=50 /  layout 
 type=log4net.Layout.PatternLayout
conversionPattern value=%property{log4net:HostName} /  
 /layout /parameter
 
 %p is interpreted as level, so what was logged into the database was:
 DEBUGroperty{log4net:HostName}
 
 so my question is what conversionPattern should I use to get 
 host name?
 and where can I see all the conversionPattern values available?
 
 


RE: couple questions

2006-05-29 Thread Nicko Cadell
 

 -Original Message-
 From: tinhuty he [mailto:[EMAIL PROTECTED] 
 Sent: 05 May 2006 19:18
 To: log4net-user@logging.apache.org
 Subject: couple questions
 
 I am pretty new to log4net, just started using it weeks ago. 
 It works great. 
 I have a couple questions:
 
 1. AdoNetAppender: all examples I could find are using insert 
 statement which is not possible in my case, could someone 
 point me some examples that using stored-procedures?

Follow the examples at:
http://logging.apache.org/log4net/release/config-examples.html
Make the following changes:

commandType value=StoredProcedure /
commandText value=name of your stored procedure /


 2. custom level: custom level is supported in new release but 
 I still confused in how to use it. for example if I want to 
 add a TRACE level between FATAL and OFF, what should I put in 
 config file and how should I log TRACE information in my program?

Probably best to have a look at extensions\net\1.0\log4net.Ext.Trace in
the log4net download, and the example
examples\net\1.0\Extensibility\TraceLogApp that demonstrates using the
Trace API.


 3. custom fields: how do I add custom fields dynamically? 

Custom fields are set via properties on the logging event. These
properties can be set directly on the logging event and are therefore
scoped to a single log, or they can be specified on the current thread
and are inherited by all logs mode on the thread.

To set properties on the thread use the ThreadContext.Properties, or
globally on the GlobalContext.Properties.

To set properties on individual LoggingEvents you will need to write a
helper method or an extension. For example see the
extensions\net\1.0\log4net.Ext.EventID extension.


 in addition, since I am going to use database as storage, how 
 can I add multiple custom fields into one databse field? the 
 reason is that if I decide to add new custom field later I 
 don't want to change the database structure.

When specifying the layout for a column you can use the PatternLayout to
generate a string by combining several different properties:

  parameter
parameterName value=@extradata /
dbType value=String /
size value=255 /
layout type=log4net.Layout.PatternLayout
  conversionPattern value=%property{prop1}|%property{prop2} /
/layout
  /parameter

Or you can use a stored procedure, pass it each property as a separate
argument and then combine the values into a single column in the stored
procedure.


 4. Large object: what is the relative better way to log large 
 objects such as DataTable, XmlNode or an Array of  custom 
 object? how do you log 2d-array or 3d-array?

If you have performance considerations you may be best served by writing
a custom appender to your requirements. The AdoNetAppender is designed
to be flexible and DB neutral. Have a look at the simple FastDbAppender
in the examples in the log4net download:

examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appender

Cheers,
Nicko



RE: Best Method For Temporary Appender

2006-05-28 Thread Nicko Cadell
Jon, 

 1. How would my startup screen class obtain a reference to 
 the MemoryAppender such that it could read the logged events 

You can create the MemoryAppender programmatically and attach it by
calling:

((log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepositor
y()).Root.AddAppender(xxx)

Then you would have the reference to the appender.

Or you can configure the appender via one of the configurators and
locate it at runtime using:

log4net.LogManager.GetRepository().GetAppenders();


 2. After startup completes and I no longer need the 
 MemoryAppender, is there a standard way of cleaning up or 
 would I just call the Close method on the MemoryAppender 
 reference. What are the consequences of removing an Appender 
 during runtime? 

You should call the RemoveAppender method on the relevant logger before
calling Close on the appender itself.

((log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepositor
y()).Root.RemoveAppender(xxx)


Cheers,
Nicko


RE: Enabling an appender at run time

2006-05-28 Thread Nicko Cadell
If you want to keep the db appender separate from the config file then
you will need to create and attach the db appenders programmatically.

If by but I want to carry over the category/log level nodes you just
mean the logger and levels then that should be fine they won't be
effected by you adding your own appenders. If you mean that the config
file should allow you to specify which appender is attached to which
logger, including your db appenders then I think that you need to use a
forwarding appender as a placeholder in the logger hierarchy. Then find
the placeholder appender using the ILoggerRepository.GetAppenders method
and attach your db appender to the forwarding appender.

Cheers,
Nicko

 -Original Message-
 From: Dag Christensen [mailto:[EMAIL PROTECTED] 
 Sent: 18 May 2006 09:47
 To: Log4NET User
 Subject: Enabling an appender at run time
 
  
 In my library's log4net setup I have two RollingFileAppenders 
 enabled by default. If the user logs on to a database 
 (depends on the application), I want to enable additional 
 AdoNetAppenders with connectionstrings pointing to the 
 database the user is logged on to (multiple choices).
  
 I believe I have three options (?)
  
 1. Use a XML file for my RollingFileAppenders, dynamically 
 adding AdoNetAppenders at runtime (if possible, what happens 
 if the XML file
 changes?)
 2. Add placeholder AdoNetAppenders to my XML file with 
 threshold = off and an empty connection string, and set these 
 at runtime? (again, the XML file can change).
 3. If I understand repositories correctly, is the suggested 
 solution to add a new repository? If so, can I copy my 
 category filters (level per
 category) to the new repository?
  
 I believe I can use the
 log4net.LogManager.GetRepository().ConfigurationChanged event 
 to detect changes to the XML file, but at this point I've 
 already lost my current settings?
 
 I'm a bit unsure how to solve this, preferably (I think..) 
 the database loggers should be kept separate from my XML 
 file, but I want to carry over the category/log level nodes.
 
 Hope this description was clear enough :-p Any suggestions 
 how to proceed to solve this ?
 
 
 Thanks,
 
 Dag Christensen
 Vestfold Butikkdata AS
 ###
 
 This message has been scanned by F-Secure Anti-Virus for 
 Microsoft Exchange.
 For more information, connect to http://www.f-secure.com/
 
 


RE: LoggerMatchFilter question

2006-05-28 Thread Nicko Cadell
You can implement a filter in your own assembly and reference it in the 
configuration file. This should mean that you can make a filter that suites 
your requirements.

Cheers,
Nicko 

 -Original Message-
 From: Marco von Frieling [mailto:[EMAIL PROTECTED] 
 Sent: 17 May 2006 12:35
 To: Log4NET User
 Subject: LoggerMatchFilter question
 
 Hello.
 
 I would log messages from all types of a specific module (e. 
 g. caching) to an extra appender, lets say to a 
 TraceAppender. Module means that the classes 
 functionalities are related to one topic, but they are in 
 different namespaces and possibly different assemblies. So I 
 thought I could use the LoggerMatchFilter for this, but it 
 does not work because the filter uses the
 string.StartsWith() method.
 But for my szenario it should use the string.Contains() 
 method. Why is does that filter not exist? Maybe you could 
 implement it in the same filter with an additional parameter
 
 param name=useContains value=true/
 
 with the default set to false, so that this extension does 
 not change current behavior?
 
 Marco
 
 
 --
 Marco von Frieling
 In den Ackern 8
 D-27374 Wittorf
 
 eMail: [EMAIL PROTECTED]
 
 Echte DSL-Flatrate dauerhaft für 0,- Euro*!
 Feel free mit GMX DSL! http://www.gmx.net/de/go/dsl
 
 


RE: Permissioning

2006-05-28 Thread Nicko Cadell
Looks like you are running an app with limited trust. See code access
security in the .net docs.

Cheers
Nicko 

 -Original Message-
 From: Drew, Stephen [mailto:[EMAIL PROTECTED] 
 Sent: 12 May 2006 11:24
 To: log4net-user@logging.apache.org
 Subject: Permissioning
 
 Hello,
  
 I am getting the following error when trying to open a 
 logfile on a local drive with plenty of disk space in a 
 folder that exists.  The file does not currently exist.
  
 Additional information: Request for the permission of type 
 'System.Security.Permissions.FileIOPermission, mscorlib, 
 Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
 failed.
 
 Can anyone point me in the direction of how to resolve this issue?
 
 Many thanks,
 Steve
 
 
 
 


RE: Interface method to request the level of a Logger?

2006-04-24 Thread Nicko Cadell
Using just Level gives the actual value set on the logger via
configuration. If the logger has not had an explicit level set on it
then it will inherit the value from its parent. Use the EffectiveLevel
property to get the currently applied level value, this is what
IsEnabledFor(Level) uses.

((log4net.Repository.Hierarchy.Logger)(log.Logger)).EffectiveLevel 

 -Original Message-
 From: Irene Altdorf [mailto:[EMAIL PROTECTED] 
 Sent: 24 April 2006 14:41
 To: 'Log4NET User'
 Subject: RE: Interface method to request the level of a Logger?
 
 Thanks for your quick response, Nicko.
 
 I tried this, but even though the logger level was error (I 
 tested 'log.IsErrorEnabled' just before the code you 
 suggested), the line below had 'null' for the level.  Would 
 there be a way around this?
 
 Thanks again,
 Irene
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Sunday, April 23, 2006 6:17 PM
 To: Log4NET User
 Subject: RE: Interface method to request the level of a Logger?
 
 Try:
 
 ((log4net.Repository.Hierarchy.Logger)(log.Logger)).Level
 
 Nicko
 
  -Original Message-
  From: Irene Altdorf [mailto:[EMAIL PROTECTED]
  Sent: 23 April 2006 22:13
  To: log4net-user@logging.apache.org
  Subject: Interface method to request the level of a Logger?
  
  Hello,
  
   
  
  Is there an interface method to get the current level of a Logger?  
  Using the ILog interface, I can determine whether certain 
 levels are 
  enabled via the IsxxxEnabled property, but I was hoping to 
 be able to 
  make one call to get the current Logger level.  It might 
 seem like an 
  odd request, but we will be passing that info on to a lower level 
  component.
  
   
  
  Sorry if I have missed something obvious.
  
   
  
  Thanks,
  
  Irene
  
   
  
  
 
 
 
 


RE: No enumerable context anymore?

2006-04-23 Thread Nicko Cadell
Use the LoggingEvent.GetProperties() method to retrieve the properties.
http://logging.apache.org/log4net/release/sdk/log4net.Core.LoggingEvent.
GetProperties.html

Cheers,
Nicko 

 -Original Message-
 From: Zimney, Christopher M. [mailto:[EMAIL PROTECTED] 
 Sent: 21 April 2006 19:43
 To: log4net-user@logging.apache.org
 Subject: No enumerable context anymore?
 
 Sorry if this has been covered a million times.
 
 I used to iterate through the MDC of a given LoggingEvent 
 when rendering.  Something like this:
 
 // Append the MDC values if any exist
 
 if(loggingEvent.MappedContext != null  
 loggingEvent.MappedContext.Count  0)
 
 {
 
 foreach(DictionaryEntry entry in loggingEvent.MappedContext)
 
 {
 
 xTxtWriter.WriteStartElement(entry.Key.ToString());
 
 xTxtWriter.WriteString(entry.Value.ToString());
 
 xTxtWriter.WriteEndElement();
 
 }
 
 }
 
 The result would be something like:
 
 Property1Value/Property1
 Property2Value/Property2
 
 How can I accomplish this with the new ThreadContextProperties?
 
 Thanks!
 
 
 


RE: logging stops under wwwroot

2006-04-23 Thread Nicko Cadell
There is a known issue with old versions of log4net FileAppender where
it tries to create the log folder even if it exists. This fails if the
credentials don't allow creating the folder, even if the folder already
exists. This may be causing the problem you are seeing. To verify make
sure that you grant the appropriate user full permissions on the log
folder and all parent folders.

This issue is fixed in the latest version of log4net - please retry this
with 1.2.10.

Cheers,
Nicko 

 -Original Message-
 From: ruchika baruah [mailto:[EMAIL PROTECTED] 
 Sent: 19 April 2006 05:39
 To: log4net-user@logging.apache.org
 Subject: logging stops under wwwroot
 
 Hi
I am having a problem with Log4net. I am using log4net 
 1.2.0.  I have a asp.net , c# web application running in  
 windows2000 server. When the application is placed in any 
 folder and created a virtual directory in IIS , it works 
 fine- log file is created (ie . file appender works fine). 
 but if I place the application under c:\inetpub\wwwroot, it 
 stops logging to the file. I have given full permission to 
 aspnet, network service user for that log folder. Although, 
 trace appender still works. 
 Can somebody pls help me.
 thanks
 Ruchika
 


RE: Log4Net 1.1.1 Documentation?

2006-04-23 Thread Nicko Cadell
Dan,

The log4net 1.1.1 release has a number of known issues and is no longer
supported.
Please use log4net 1.2.10 from:
http://logging.apache.org/log4net/downloads.html

Regards,
Nicko  

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 19 April 2006 15:59
 To: Log4NET User
 Subject: Re: Log4Net 1.1.1 Documentation?
 
 I realize that it is an old release, but I still am very 
 hesitant to consider using a beta release in a commercial 
 product.  If it is stable, then why hasn't there been a 
 general release?  It seems a little odd to me to go that long 
 without a general release, even if it is an open-source 
 product.  Version 1.1.1 seems to have everything that we 
 really need, although the ADO.NET appender would be nice.
 
 Dan
 
 From Ron Grabowski [EMAIL PROTECTED] on 18 Apr 2006:
 
  Log4net 1.1.1 was released in 2002. Its over 4 years old. Don't use 
  that. A lot of people consider 1.2.0 beta 8 and anything after that
  (1.2.9 beta, and the recently announced 1.2.10) to be stable. 
  
  The documentation on the log4net website is for 1.2.9 beta.
  
  I recommend coding against the download on this page:
  
   http://logging.apache.org/log4net/downloads.html
  
  --- [EMAIL PROTECTED] wrote:
  
   Does anyone know where I can get my hands on a copy of the Log4Net
   1.1 Manual?  I found the API documentation in the ZIP 
 file, but that 
   isn't very helpful for a newbie like me trying to learn 
 how to use 
   and configure Log4Net.  Also, I found the Log4Net 1.2 
 Manual online, 
   but I'm not sure what all the differences are between 
 1.1.1 and 1.2.
   The reason I'm using 1.1.1 is that the product I'm 
 working on is a 
   commercial product, and so far as I know 1.1.1 is the most recent 
   non-Beta release available.  I don't feel comfortable 
 using a beta 
   version of anything in a commercial software product.
   
   Thanks in advance,
   
   Dan
   
  
  
 
 


RE: Interface method to request the level of a Logger?

2006-04-23 Thread Nicko Cadell
Try:

((log4net.Repository.Hierarchy.Logger)(log.Logger)).Level

Nicko

 -Original Message-
 From: Irene Altdorf [mailto:[EMAIL PROTECTED] 
 Sent: 23 April 2006 22:13
 To: log4net-user@logging.apache.org
 Subject: Interface method to request the level of a Logger?
 
 Hello,
 
  
 
 Is there an interface method to get the current level of a 
 Logger?  Using the ILog interface, I can determine whether 
 certain levels are enabled via the IsxxxEnabled property, but 
 I was hoping to be able to make one call to get the current 
 Logger level.  It might seem like an odd request, but we will 
 be passing that info on to a lower level component.
 
  
 
 Sorry if I have missed something obvious.
 
  
 
 Thanks,
 
 Irene
 
  
 
 


RE: BufferingForwardingAppender, another question

2006-04-23 Thread Nicko Cadell
The BufferingForwardingAppender only depends on the number of events in
the buffer not the length of time the events have been in the queue. It
would add considerable complexity to the buffer to expire events after a
period of idle time.

Nicko

 -Original Message-
 From: Marco von Frieling [mailto:[EMAIL PROTECTED] 
 Sent: 12 April 2006 12:15
 To: Log4NET User
 Cc: log4net-user@logging.apache.org
 Subject: BufferingForwardingAppender, another question
 
 Hi.
 
 Yesterday I had the problem that an NHibernate operation took 
 3202 ms and the complete callback about 6 seconds, which 
 obviously is too long. So I configured an extra logger for 
 the NHibernate namespace hierarchy with level INFO instead of 
 DEBUG an the same operation has finished after 76 ms. But 
 logging root with DEBUG and NHibernate only with info does 
 not work for us during development. So I thaught it would be 
 the best thing to use a BufferingForwardingAppender 
 forwarding to the FileAppender.
 
 Then my project leader asked me what happens when the buffer 
 configured to 200 messages contains only 100 messages when 
 the request ends and no other request comes in for a while. 
 When will these 100 messages be written into the log file, 
 only if the buffer is full? Or is there a way to flush the 
 buffer when the current thread or process is idle?
 
 Thanks, Marco
 
 --
 Marco von Frieling
 In den Ackern 8
 D-27374 Wittorf
 
 eMail: [EMAIL PROTECTED]
 
 Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ...
 Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
 
 


RE: Accessing Appender that was created via config file?

2006-04-23 Thread Nicko Cadell
 

 -Original Message-
 From: Daniel Bachler [mailto:[EMAIL PROTECTED] 

[snip]

 Is there a possibility to get the reference to a certain 
 Appender that was created via config file magic? Something 
 similar to LogManager.GetLogger(), along the lines of 
 LogManager.GetAppenderByName(string name)? 

You can get all the appenders using:

LogManager.GetLoggerRepository().GetAppenders()

You will need to iterate through the list and find your named appender.


 My old, custom logging 
 framework had a function called SetJob(string currentJob) 
 that would output the string given to what is called the 
 appenders in log4net, but there would be special handling to 
 update a small label in the UI to inform the user of what the 
 app is currently doing.

If the job is metadata for the log events that occur then the job name
should be attached as a property to the logging events.
If your jobs run on a single thread then the easiest way to do this is
using the ThreadContext

void Job1()
{
  using(ThreadContext.Stacks[Job].Push(job-name))
  {
... statements and methods to perform job1
... any log statements here will have the Job property set to
'job-name'
  }
}


You can retrieve the value of the Job property by using the
LookupProperty method on the LoggingEvent object.

Cheers,
Nicko




RE: Layout settings not applied to custom event appender

2006-04-21 Thread Nicko Cadell
loggingEvent.RenderedMessage has nothing to do with the Layout. The 
LoggingEvent does not know about layouts.
The Message is only part of the LoggingEvent, there are lots of other parts 
like the ThreadName, the TimeStamp, the Properties, the Level. The Message is 
just the one of these parts.

In the following example user code the message is a string This is the 
message:

log.Debug(This is the message, anException);

However the Message can be any object. e.g.

log.Debug(myStrangeObject);

This message object is then _rendered_ into a string by the 
log4net.ObjectRenderer classes. You can define your own IObjectRenderer that is 
used to convert your custom object to a string. By default the ToString() 
method will be used.

The loggingEvent.RenderedMessage is the message object as a String having been 
passed through the appropriate renderers.

The concept and application of Layouts is up to the individual Appender. Some 
appenders don't use layouts at all. 
Note that the Layout takes all of the properties of the LoggingEvent (including 
the RenderedMessage) and converts that to a single String. This is typically 
used where the Appender wants to write the LoggingEvent to a text orientated 
data source, e.g. a file or the console.

Cheers,
Nicko

 -Original Message-
 From: Hans-Theo Jungeblut [mailto:[EMAIL PROTECTED] 
 Sent: 21 April 2006 08:19
 To: Log4NET User
 Subject: AW: Layout settings not applied to custom event appender
 
 Thanks for the hint, using the loggingEvent.RenderedMessage() 
 is working.
 
 I am just wondering why using loggingEvent.RenderedMessage 
 does not work.
 This was the way I first tried to do it. 
 
 Is this a bug, or am I missing something?
 
 Greetings from Osnabrueck,
 Theo
 
 -Ursprüngliche Nachricht-
 Von: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Gesendet: Donnerstag, 20. April 2006 20:59
 An: Log4NET User
 Betreff: RE: Layout settings not applied to custom event appender
 
 The Layout is designed to convert the LoggingEvent object 
 into a String.
 You need to use the Layout yourself in your Append method. 
 
 Have a look at the DebugAppender.cs in the log4net source 
 code for an example of this. The DebugAppender uses the 
 RenderLoggingEvent() helper method provided by the 
 AppenderSkeleton base class.
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Hans-Theo Jungeblut [mailto:[EMAIL PROTECTED]
  Sent: 20 April 2006 08:41
  To: log4net-user@logging.apache.org
  Subject: Layout settings not applied to custom event appender
  
  Hallo everyone,
  I have implemented a really simple event appender, which 
 allows me to 
  forward the message from the Log4Net Framework in my own 
 application.
  This also works fine, but the layout settings from the 
 configuration 
  file are not applied to my appender. The same Layout settings work 
  fine for the default appenders, which I removed for 
 simplification. I 
  added the appender source code and config below. Hopefully somebody 
  can tell me how to fix this problem.
  
  Thx in advance,
  Theo Jungeblut
  
  Settings:
  --
  Log4Net Version 1.2.9 beta
  OS: Win XP SP2
  .Net:   1.1 (VS2003)
  Assembly type:  DLL 
  Application type:   windows application
  
  
  Appender Source code:
  --
  --
  -
  using log4net.Appender;
  using log4net.Core;
  using log4net.Layout;
  using MyEvents;
  
  namespace MyAppender
  {
  /// summary
  /// Adapts the Log4Net message for inner application usage.
  /// When configured in the Log4Net configuration, each 
 log message
  /// results into an OnMessageSent event.
  /// /summary
  public class EventAppender: AppenderSkeleton
  {
  #region - Private Fields
  -
  /// summary
  /// Event raised when message is send
  /// /summary
  public event MessageSentEventHandler MessageSent;
  #endregion
  
  
  #region - Private Fields
  -
  /// summary
  /// Immediate flush means that the underlying 
 writer or output 
  stream
  /// will be flushed at the end of each append operation.
  /// /summary
  /// remarks
  /// para
  /// Immediate flush is slower but ensures that 
 each append request 
  is
  /// actually written. If see
  cref=ImmediateFlush/ is set to
  /// cfalse/c, then there is a good chance 
 that the last few
  /// logs events are not actually written to 
 persistent media if and
  /// when the application crashes.
  /// /para
  /// para
  /// The default value is ctrue/c./para
  /// /remarks

RE: Uncaught IndexOutOfRangeException in log4net 1.2.9 Beta

2006-04-21 Thread Nicko Cadell
This is a known issue fixed in log4net 1.2.10. Please download the
latest version from http://logging.apache.org/log4net/downloads.html

The exception is actually coming from an internal error handler. The
Appender must have thrown an exception for this code path to be
activated. The log4net.Util.LogLog.Error is used to log internal errors.

The log4net.Util.LogLog.Error writes to the console, and the
System.Diagnostics.Trace handler. It looks like Console code isn't
working correctly.


This is not recommended but If you must use log4net 1.2.9 then you can
disable the internal error logging by setting the following
appSettings in your application's .config file:

appSettings
  add key=log4net.Internal.Quiet value=true /
/appSettings

Cheers,
Nicko


 -Original Message-
 From: Ian Dykes [mailto:[EMAIL PROTECTED] 
 Sent: 21 April 2006 16:18
 To: log4net-user@logging.apache.org
 Subject: Uncaught IndexOutOfRangeException in log4net 1.2.9 Beta
 
 Hi,
 
 We're in the process of updating our logging from version 
 1.2.0 beta 8 (DLL version 1.2.0.30714) to the 1.2.9 beta and 
 are experiencing an uncaught error when our test system is 
 placed under load.
 
 We're running version 1.1 of the MS .Net framework on Windows 
 2003 Server, and have also seen this on Windows XP Pro SP2.
 
 We have a server process which catches all exceptions and 
 logs them as errors.  The stack trace we are getting is as follows:
 
 ERROR[slf5s.PRIORITY]
 (null)[slf5s.NDC]
 2132[slf5s.THREAD]
 com.esendex.ems.ScheduledSubmissionServer[slf5s.CATEGORY]
 com.esendex.common.statusservice.Status.LogError(:0)[slf5s.LOCATION]
 Error calling ProcessMessages[slf5s.MESSAGE]
 
 System.IndexOutOfRangeException: Probable I/O race condition 
 detected while copying memory.  The I/O package is not thread 
 safe by default.  In multithreaded applications, a stream 
 must be accessed in a thread-safe way, such as a thread-safe 
 wrapper returned by TextReader's or TextWriter's Synchronized 
 methods.  This also applies to classes like StreamWriter and 
 StreamReader.
 
 Server stack trace: 
at System.Buffer.InternalBlockCopy(Array src, Int32 
 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 
 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.SyncTextWriter.WriteLine(String value)
at log4net.Util.LogLog.Error(String message, Exception exception)
at 
 log4net.Util.AppenderAttachedImpl.AppendLoopOnAppenders(Loggin
 gEvent loggingEvent)
at 
 log4net.Repository.Hierarchy.Logger.CallAppenders(LoggingEvent
  loggingEvent)
at log4net.Repository.Hierarchy.Logger.ForcedLog(Type 
 callerStackBoundaryDeclaringType, Level level, Object 
 message, Exception exception)
at log4net.Repository.Hierarchy.Logger.Log(Type 
 callerStackBoundaryDeclaringType, Level level, Object 
 message, Exception exception)
at log4net.Core.LogImpl.Debug(Object message)
at 
 com.esendex.ems.datamappers.ScheduledSubmissionBatchDM.SelectB
 atchForDateTime(DateTime date)
at 
 com.esendex.ems.implementation.facades.ScheduledSubmissionFaca
 deImpl.GetBatchesToSubmit(DateTime date)
at 
 com.esendex.ems.facades.ScheduledSubmissionFacade.GetBatchesTo
 Submit(DateTime date)
at 
 System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProc
 essMessage(MethodBase mb, Object[] args, Object server, Int32 
 methodPtr, Boolean fExecuteInContext, Object[] outArgs)
at 
 System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcess
 Message(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
 
 Exception rethrown at [0]: 
at 
 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(
 IMessage reqMsg, IMessage retMsg)
at 
 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Messag
 eData msgData, Int32 type)
at 
 com.esendex.ems.facades.ScheduledSubmissionFacade.GetBatchesTo
 Submit(DateTime date)
at com.esendex.ems.ScheduledSubmissionServer.ProcessMessages()
at com.esendex.ems.ScheduledSubmissionServer.Run()
 
 The server process is logging to one file, while the Debug 
 line (the line at log4net.Core.LogImpl.Debug(Object 
 message) in the stack trace) is meant to log to a different 
 file (which other threads will be logging to).  The server 
 code is in a DLL that is late loaded from the GAC by a host 
 EXE program.  This is logging correctly as the above trace is 
 from that log.  The server DLL then calls through to a COM+ 
 component.  The COM+ component late loads an implementation 
 assembly from the GAC.  It is the logging within this 
 implementation DLL that is throwing the exception.
 
 I'm logging to a log4net.Appender.RollingFileAppender with 
 the following configuration:
 
 appender name=EsendexRollingFileAppender 
 type=log4net.Appender.RollingFileAppender
   param name=File value=${log.dir.unix}/${namespace}.txt /
   param name=AppendToFile value=true /
   param 

RE: Layout settings not applied to custom event appender

2006-04-20 Thread Nicko Cadell
The Layout is designed to convert the LoggingEvent object into a String.
You need to use the Layout yourself in your Append method. 

Have a look at the DebugAppender.cs in the log4net source code for an
example of this. The DebugAppender uses the RenderLoggingEvent() helper
method provided by the AppenderSkeleton base class.

Cheers,
Nicko

 -Original Message-
 From: Hans-Theo Jungeblut [mailto:[EMAIL PROTECTED] 
 Sent: 20 April 2006 08:41
 To: log4net-user@logging.apache.org
 Subject: Layout settings not applied to custom event appender
 
 Hallo everyone,
 I have implemented a really simple event appender, which 
 allows me to forward the message from the Log4Net Framework 
 in my own application.
 This also works fine, but the layout settings from the 
 configuration file are not applied to my appender. The same 
 Layout settings work fine for the default appenders, which I 
 removed for simplification. I added the appender source code 
 and config below. Hopefully somebody can tell me how to fix 
 this problem.
 
 Thx in advance,
 Theo Jungeblut
 
 Settings:
 --
 Log4Net   Version 1.2.9 beta
 OS:   Win XP SP2
 .Net: 1.1 (VS2003)
 Assembly type:DLL 
 Application type: windows application
 
 
 Appender Source code:
 --
 --
 -
 using log4net.Appender;
 using log4net.Core;
 using log4net.Layout;
 using MyEvents;
 
 namespace MyAppender
 {
   /// summary
   /// Adapts the Log4Net message for inner application usage.
   /// When configured in the Log4Net configuration, each 
 log message
   /// results into an OnMessageSent event.
   /// /summary
   public class EventAppender: AppenderSkeleton
   {
   #region - Private Fields
 -
   /// summary
   /// Event raised when message is send
   /// /summary
   public event MessageSentEventHandler MessageSent;
   #endregion
   
   
   #region - Private Fields
 -
   /// summary
   /// Immediate flush means that the underlying 
 writer or output stream
   /// will be flushed at the end of each append operation.
   /// /summary
   /// remarks
   /// para
   /// Immediate flush is slower but ensures that 
 each append request is 
   /// actually written. If see 
 cref=ImmediateFlush/ is set to
   /// cfalse/c, then there is a good chance 
 that the last few
   /// logs events are not actually written to 
 persistent media if and
   /// when the application crashes.
   /// /para
   /// para
   /// The default value is ctrue/c./para
   /// /remarks
   private bool immediateFlush;
   #endregion
   
   
   #region - Public Properties
 -
   #region ImmediateFlush
   /// summary
   /// Gets or sets a value that indicates whether 
 the appender will 
   /// flush at the end of each write.
   /// /summary
   /// remarks
   /// paraThe default behavior is to flush at 
 the end of each 
   /// write. If the option is set tocfalse/c, 
 then the underlying 
   /// stream can defer writing to physical medium 
 to a later time. 
   /// /para
   /// para
   /// Avoiding the flush operation at the end of 
 each append results 
   /// in a performance gain of 10 to 20 percent. 
 However, there is safety
   /// trade-off involved in skipping flushing. 
 Indeed, when flushing is
   /// skipped, then it is likely that the last 
 few log events will not
   /// be recorded on disk when the application 
 exits. This is a high
   /// price to pay even for a 20% performance gain.
   /// /para
   /// /remarks
   public bool ImmediateFlush
   {
   get
   {
   return immediateFlush;
   }
   set
   {
   immediateFlush = value;
   }
   }
   #endregion
   
   #region RequiresLayout
   /// summary
   /// This appender requires a see 
 cref=Layout/ to be set.
   /// /summary
   /// valuectrue/c/value
   /// remarks
   /// para
   /// This appender requires a see 
 cref=Layout/ to be set.
   /// 

RE: Question about the RollingFileAppender

2006-04-20 Thread Nicko Cadell
 

  Random question, but is the + in FileAppender+MinimalLock some 
  sort of special notation? Haven't seen this before...
 
 The + notation is used to specify an inner class:
 
This is standard .NET behaviour as supported by the Type.GetType(String)
method.



[ANN] log4net 1.2.10 Released

2006-04-19 Thread Nicko Cadell
log4net 1.2.10 Released
---

Log4net developers are proud to announce the release of log4net 1.2.10. 
This release includes many enhancements and bug fixes.

The log4net website documentation has been updated to be in sync with 
this release.

The release notes are available from
http://logging.apache.org/log4net/release/release-notes.html

This release can be downloaded from
http://logging.apache.org/log4net/downloads.html

For more information about log4net please go to
http://logging.apache.org/log4net


Please note that log4net is an currently undergoing incubation at the 
Apache Software Foundation (ASF), sponsored by the Apache Logging 
Services project. While incubation status is not necessarily a
reflection 
of the completeness or stability of the code, it does indicate that the 
project has yet to be fully endorsed by the ASF.


Nicko Cadell
log4net dev


RE: Log4Net suddenly stops logging

2006-04-02 Thread Nicko Cadell
Sven,

As far as I know this isn't a known problem.
Can you reproduce this issue with log4net internal debugging enabled?
http://logging.apache.org/log4net/release/faq.html#internalDebug
Or do you have a simple test case that reproduces this issue?

Cheers,
Nicko 

 -Original Message-
 From: Lohberg, Sven [mailto:[EMAIL PROTECTED] 
 Sent: 30 March 2006 08:52
 To: log4net-user@logging.apache.org
 Subject: Log4Net suddenly stops logging
 
 Hi,
 
  
 
 I am using log4net 1.2.0-beta8 in a multithreaded 
 windows-service written in C#. The application is using the 
 RollingFileAppender. While performing some load tests, where 
 a large number of entries have been written, suddenly it can 
 happen that no more log lines are written while the 
 application itself still continues to work properly.
 
  
 
 I could read from previous older support mails, that such an 
 issues already has been reported before, but I could not find 
 any explanation of the reason and how to solve it.
 
  
 
 Is this a known problem with an existing fix?
 
  
 
 Regards
 
 Sven
 
  
 
 i.A. Sven Lohberg
 
 Senior Solutions Architect
 
 Aspect Communications GmbH
 
 Subsidiary of Aspect Software, Inc.
 
 Kreuzerkamp 7-11
 
 D-40878 Ratingen
 
  
 
 +49 (0) 2102 396 6268 office
 
 +49 (0) 2102 396 6201 fax
 
 +49 (0) 172 2968928 mobile
 
 [EMAIL PROTECTED]
 
 www.aspect.com
 
  
 
 Transforming the way companies interact with their customers.(tm)
 
 


RE: Logging of the errors in logging

2006-04-02 Thread Nicko Cadell
Log4net is designed to be a best effort logging system, not a reliable
system. If there is a problem logging log4net will not propagate errors
into the calling application. 
While the current internal error handling is not flexible enough it is
unlikely that it will be changed to accommodate a completely reliable
logging scenario. 

Regards,
Nicko

 -Original Message-
 From: unegov [mailto:[EMAIL PROTECTED] 
 Sent: 30 March 2006 08:43
 To: log4net-user@logging.apache.org
 Subject: Logging of the errors in logging
 
 Log4net is a great tool but I'm not fully satisfied how 
 log4net deals with errors in logging. In my project it is 
 necessary not to lose any logging messages if the logging is 
 on so I would prefer log4net threw exceptions rather than 
 wrote errors of logging into Console.Error and Trace as 
 information messages. I'm ready to catch such sort of 
 exceptions at the top level of my code. But I have no way to 
 override the behaviour of the LogLog class.
 
 All I can do is to intercept Console.Error and rethrow 
 exceptions in the interception code but in this case I wont 
 always get complete exception messages and it doesnt look 
 beautiful at all.
 
 Another way is to rebuild log4net but I will get a lot of 
 problems with other projects (nhibernate) which references 
 native assembly of the log4net. So the question: is it 
 possible to add to log4net different strategies of managing 
 errors in logging? Is there any other way to cope with the problem?
 
 ErrorHandlers used in appenders don't cover all possible errors. I.e.
 if some error in configuring occures it is most likely that 
 no appender will be added to logger.
 
 Thanks.
 
 Best regards,
 Stepan Unegov.
 
 
 


RE: Repeat ignores messages

2006-03-27 Thread Nicko Cadell
 

 -Original Message-
 From: Stefan Bodewig [mailto:[EMAIL PROTECTED] 
 Sent: 28 January 2006 10:34
 To: log4net-user@logging.apache.org
 Subject: Re: Repeat ignores messages
 
 
 I've once done something similar for an in-house (Java) 
 logging framework in a past job.  The way I implemented it 
 would translate into an appender that was a decorator around 
 another appender which just keeps track of the last message 
 it logged, the memory overhead is minimal.  In addition I had 
 a thread that made sure log statements were not delayed, so 
 if the last AB log never happened a trigger would cause the 
 last message repeated two times after some time.
 
 Stefan
 

Log4net appenders can be nested. It should be straightforward to write
an appender that does the same as your java version. The
ForwardingAppender would be the best appender to subclass.

Cheers,
Nicko


RE: Question about NDC and appenders

2006-03-26 Thread Nicko Cadell
The NDC is metadata attached to the logging event. It is not used in
routing the event to an appender. The NDC is a string which is built by
concatenating the names of the nested contexts.

The best you can do is route all logging events to the appender and then
use a filter on the appender to only allow the events with the correct
NDC data to be logged. You may be able to use the
log4net.Filter.NdcFilter to do this, but you may be better off writing a
custom filter.

In your case it sounds like you are not actually using the NDC to build
up a nested context (think call stack for log message), so you may want
to just set a thread local context property instead. See the
log4net.ThreadContext class for details.

Nicko

 -Original Message-
 From: Morten Andersen [mailto:[EMAIL PROTECTED] 
 Sent: 25 March 2006 10:25
 To: Log4NET User
 Subject: Re: Question about NDC and appenders
 
 I forgot to includethis in my last mail.
 
 This is what I have today:
 appender name=Protocol_P1 
 type=WebHandlerRollingFileAppender/
 
 logger name=Protocol_P1_Receiver
 appender-ref ref=Protocol_P1/
 /logger
 
 logger name=Protocol_P1_Handler
 appender-ref ref=Protocol_P1/
 /logger
 
 
 Here I reference two loggers to the appender. What I need to 
 do is to reference a NDC contexts (Protocol_P1_Receiver and 
 Protocol_P1_Handler) to the Protocol_P1 appender.
 
 - Morten
 
 Ron Grabowski wrote:
  I don't understand the question. By specific NDC context do 
 you mean 
  you're using nested using() statements?
 
  using(ThreadContext.Stacks[NDC].Push(first push)) {  
  using(ThreadContext.Stacks[NDC].Push(second push))  {
log.Info(This log message has two NDC entires);  }  
 log.Info(This 
  log message has one NDC entry); }
 
  --- Morten Andersen [EMAIL PROTECTED] wrote:
 

  Can I configure log4net to route messages from a specific 
 NDC context 
  to a appender?
 
  - Morten
 
  
 
 


RE: ADONetAppender.ActivateOptions() causes Connection Leak?

2006-03-26 Thread Nicko Cadell
This is a bug, I will create a bug to track this.

Cheers,
Nicko

 -Original Message-
 From: Craig Boland [mailto:[EMAIL PROTECTED] 
 Sent: 21 March 2006 12:43
 To: log4net-user@logging.apache.org
 Subject: Re: ADONetAppender.ActivateOptions() causes Connection Leak?
 
 It appears that calling ActivateOptions() successively will 
 cause a connection leak, since is calls the
 InitializeDatabaseConnection() method, which creates and 
 opens a new connection instance with each call.
 
 I'm not too familiar with the AdoNetAppender. Is there a way 
 to close it programmatically before calling 
 ActivateOptions()? If so, that would be a work-around.
 
 It seems to me that a method named
 InitializeDatabaseConnection would check the current 
 instance and close it before opening a new one.
 
 Here's what I'd add to the
 InitializeDatabaseConnection() method:
 
 private void InitializeDatabaseConnection() {
   try
   {
 // Close the current instance
 if(m_dbConnection != null)
 {
 m_dbConnection.Dispose();
 }
 
 // Create the connection object
 m_dbConnection =
 (IDbConnection)Activator.CreateInstance(ResolveConnectionType());
 
 //...
 
 
   Subject: ADONetAppender.ActivateOptions() causes
  Connection Leak?
  Date: Mon, 20 Mar 2006 17:21:21 -0700
  From: Wanner, Nick [EMAIL PROTECTED]
  To: log4net-user@logging.apache.org
  
  I am modifying the buffer size and the connection string of 
  ADONetAppenders programmatically and I am getting a SqlConnection 
  leak.
  The number of open connections to SQL Server grows to the max 
  connection pool size when I do this repeatedly.
   
  The leak occurs when I call ActivateOptions on the ADONetAppender 
  after I set its BufferSize and ConnectionString.  The documentation 
  says that you need to call ActivateOptions after you modify the 
  appenders configuration.  The ActivateOptions method creates a new 
  connection and overwrites the ADONetAppenders connect member 
  m_dbConnection with the new instance.  The leak occurs 
 because the the 
  old connection is not closed.
   
  Here is basically what I am doing:
  ...
 
 ((log4net.Appender.BufferingAppenderSkeleton)logAppender).BufferSize
  =
  size;
 
 ((log4net.Appender.ADONetAppender)logAppender).ConnectionString
  =
  ADOConnectionString;
 
 ((log4net.Appender.ADONetAppender)logAppender).ActivateOptions();
   
  I am doing something wrong or is this a bug?
   
  thanks,
  Nick
  mailto:'log4net-user@logging.apache.org'
  
 
 
 


RE: Logging to particular levels + buffering smtpappender

2006-03-26 Thread Nicko Cadell
 

 -Original Message-
 From: electroteque [mailto:[EMAIL PROTECTED] 
 Sent: 17 March 2006 05:09
 To: Log4NET User
 Subject: Re: Logging to particular levels + buffering smtpappender
 
 im taking it from the example though ?
 
  evaluator type=log4net.Core.LevelEvaluator
  threshold value=ERROR/
  /evaluator

If you just want the smtp appender to log errors then use:

appender name=SmtpAppender type=log4net.Appender.SmtpAppender
  threshold value=ERROR/
  subject value=Errors with WMSLogParser /
  to value= /
  from value= /
  smtpHost value= /
  authentication value=basic/
  username value=/
  password value=/
  bufferSize value=512 /
  layout type=log4net.Layout.PatternLayout
conversionPattern
  value=%message%newline /
  /layout
/appender

This will buffer 512 errors before sending the email. The email will be
sent when the app exits regardless of the number of errors logged.


 
 Is there anyway for the filelog to only log info , warn and 
 error levels and the debug level will be just for debugging 
 in the console ?

If you want to log INFO and above via the file appender then set the
threshold on the file appender:

appender name=fileappender type=log4net.Appender.FileAppender
  threshold value=INFO /
  ...

root
  appender-ref name=fileappender /
  appender-ref name=consoleappender /
/root

All levels will be sent to the console appender. If you only want to see
DEBUG output on the console, then you need to specify a level filter on
the console appender:

appender name=consoleappender
type=log4net.Appender.ConsoleAppender
  filter type=log4net.Filter.LevelMatchFilter
levelToMatch value=DEBUG /
  /filter
  ...

Cheers,
Nicko

 
 On 17/03/2006, at 4:01 PM, Ron Grabowski wrote:
 
  Try adding a threshold node to the appender node:
 
   appender name=SmtpAppender type=log4net.Appender.SmtpAppender
threshold value=INFO/
subject value=Errors with WMSLogParser /
to value= /
from value= /
smtpHost value= /
authentication value=basic/
username value=/
password value=/
bufferSize value=512 /
layout type=log4net.Layout.PatternLayout
 conversionPattern
  value=%message%newline /
/layout
   /appender
 
  --- electroteque [EMAIL PROTECTED] wrote:
 
 
  On 17/03/2006, at 11:42 AM, electroteque wrote:
 
  Hi there, I was wondering if there was a possibility of being able
  to
  log to file all levels except the debug level which i want the
  console
  only to display ? Also how is it possible to buffer all the logs
  going
  to smtp appender and send it once the program has finished or
  exiting
  with an error ? I only one to recieve one email not many really.
  Let
  me know.
 
 
  Here is my smtp config, the level is being ignored its sending all 
  log levels !
 
  appender name=SmtpAppender type=log4net.Appender.SmtpAppender
 subject value=Errors with WMSLogParser /
 to value= /
 from value= /
 smtpHost value= /
 authentication value=basic/
 username value=/
 password value=/
 bufferSize value=512 /
 lossy value=false /
 evaluator type=log4net.Core.LevelEvaluator
 threshold value=ERROR/
 /evaluator
 layout type=log4net.Layout.PatternLayout
 conversionPattern 
 value=%newline%d{dd MMM  HH:mm:ss} 
  [%thread] %-5level %logger - %message%newline%newline%newline /
 /layout
 /appender
 
 
 
 
 


RE: adding a from title for the smtp appender

2006-03-26 Thread Nicko Cadell
If by title you mean a friendly name then yes you can specify this as
normal for an email address.

from value=quot;Friendly name goes herequot;
lt;[EMAIL PROTECTED]gt; /

 -Original Message-
 From: electroteque [mailto:[EMAIL PROTECTED] 
 Sent: 17 March 2006 01:36
 To: 'Log4NET User'
 Subject: adding a from title for the smtp appender
 
 Hi there, i was wondering if there is a way to add a from 
 title in the smtp appender, it just uses the alias.
 
 
 


RE: Help with XmlLayoutBase

2006-03-26 Thread Nicko Cadell
If you want to generate an XML log file using the default layout, you
should use the log4net.Layout.XmlLayout. The only property you can
specify on the XmlLayout is the Prefix. This is the namespace prefix to
use on all elements output.

If you want a different XML layout then you will need to subclass the
XmlLayoutBase. The best examples of subclassing the XmlLayoutBase are
the XmlLayout and the XmlLayoutSchemaLog4j. The source for these can be
found in the log4net download.

Cheers,
Nicko 

 -Original Message-
 From: Macagno, Julian [mailto:[EMAIL PROTECTED] 
 Sent: 09 March 2006 14:49
 To: log4net-user@logging.apache.org
 Subject: Help with XmlLayoutBase
 
 Hi Everyone,
 
 I interested in logging with log4net generating an XML file 
 with the log4net.Layout.XmlLayoutBase Skeleton.
 Can anybody help me out on what parameters I need to declare 
 under the layout field, like Schema, etc...
 
 Or maybe someone has an example of developing with the 
 log4net.Layout.XmlLayoutBase
 
 Thks in advance for any help.
 
 Julian.
 
 


RE: SmtpAppender

2006-03-26 Thread Nicko Cadell
You will have to define 2 separate appenders.

root
  appender-ref name=appender1 /
/root

logger name=Log4net.MainForm additivity=false
  appender-ref name=appender2 /
/logger

The additivity flag on the logger prevents it inheriting the appenders
from the root.

Cheers,
Nicko

 -Original Message-
 From: Vladimir Kovalenko [mailto:[EMAIL PROTECTED] 
 Sent: 09 March 2006 08:27
 To: log4net-user@logging.apache.org
 Subject: SmtpAppender
 
 I have SmtpAppender configured to send messages to  
 [EMAIL PROTECTED] Now I want to configure Log4net.MainForm 
 logger to send messages to [EMAIL PROTECTED] and all the rest 
 loggers to [EMAIL PROTECTED] Can I do that with configuration file?
 
  
 
 Best Regards,
 
 Vladimir Kovalenko
 
 


RE: Compression tool

2006-03-03 Thread Nicko Cadell
 

 -Original Message-
 From: Göran Roseen [mailto:[EMAIL PROTECTED] 

 True!
 I have been thinking all along as new requests for features 
 in the rolling file appender comes in; This should really be 
 done with logrotate, a Unix tool that is specialized in 
 rotating log files.
 
 Today I googled around a little, and to my astonishment I 
 realized that it seems like no one has made a windows port of 
 logrotate. Really strange!

The best I could find is rotatelog, which is written in Perl and therefore may 
run on Windows with the help of ActiveState Perl.
http://www.interhack.net/projects/rotatelog/

The main problem with this approach on Windows is that files open for writing 
are locked and cannot be renamed. On UNIX based file systems you can rename a 
file while it is locked and the application will continue to write to it. 
Typically after renaming the log file you would send the application a HUP 
signal to cause it to close the current log file and open a new log file with 
the original name. There is no standard way of signalling applications in 
Windows.

Personally I think that the current RollingFileAppender is too complex and we 
would benefit greatly from a more pluggable approach similar to the new 
implementation in log4j:

http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apache/log4j/rolling/

At least with a plugin model it would be simpler for users to define their own 
behaviours when the out of the box solution does not fit.

Cheers,
Nicko


RE: log4NET from a class library (dll)

2006-03-02 Thread Nicko Cadell
If you DLL is part of an application that is not using log4net or if you
want the configuration for you assembly to be loaded from a different
config file to that for the rest of the application, you need create a
separate logging Repository for your assembly (DLL).

If you want to configure log4net programmatically you can call one of
the log4net.Config.XmlConfigurator.Configure() methods. Either the one
that takes a FileInfo passing the path to the config file (e.g.
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) or the
method with no parameters that uses the .NET configuration APIs to load
the configuration from the .config file.

Alternatively add the following assembly level attributes to you DLL.
You can do these in any source file you want, not just the
AssemblyInfo.cs.

[assembly: log4net.Config.Repository(NameOfYourAssemblyHere)]
[assembly: log4net.Config.XmlConfigurator()]

The name of you assembly just needs to be a unique string. This will
load the configuration from the application's .config file.

If you want to load your configuration from a different file you can
use:

[assembly: log4net.Config.XmlConfigurator(ConfigFile=log4net.config)]

The file path is relative to the application base directory.

Cheers,
Nicko


 -Original Message-
 From: Ramesh Vijayaraghavan [mailto:[EMAIL PROTECTED] 
 Sent: 02 March 2006 15:42
 To: log4net-user@logging.apache.org
 Subject: log4NET from a class library (dll)
 
 
 Hello,
 
 I want to log messages from a class library(dll).This dll is 
 called by a third party application on which I have no 
 control. In other words, I cannot make the third party 
 application read a app.config file.
 
 A dll by its very nature does not allow loading of app.config 
 file. I am also not able to find an AssemblyInfo.cs file to 
 make changes to point to the config file.
 
 I can hard code log4net as follows
 
 FileAppender appender =  new log4net.Appender.FileAppender(
   new 
 log4net.Layout.PatternLayout(%d [%t]%-5p %c;- 
 %m%n),logFile); // using a FileAppender with a PatternLayout 
 log4net.Config.BasicConfigurator.Configure(appender);
 
 
 But this means that the log file is hardcoded and cannot be 
 configured. How can I make the dll read the config file.
 
 
 Thanks,
 scoliodonAThotmailDOTcom
 
 
 


RE: Double configuration and SmtpAppender configuration

2006-03-02 Thread Nicko Cadell
Loggers can only have one level. If you need to have more control over
the logging performed by an appender you can set its threshold level.
If that is not sufficient you can attach several different filters to
the appender that determine if the event should be output, you can even
write your own filters.
http://logging.apache.org/log4net/release/manual/introduction.html#filte
rs

So my suggestion would be to set the threshold on the CustomAppender
like so:

root
  level value=ALL /
/root

logger name=Log4net.MainForm
  appender-ref ref=AdoNetAppender /
  appender-ref ref=SmtpAppender /
  appender-ref ref=CustomAppender /
/logger 

appender name=CustomAppender type=..
  threshold value=WARN /
  ...
/appender

Cheers,
Nicko

 -Original Message-
 From: Vladimir Kovalenko [mailto:[EMAIL PROTECTED] 
 Sent: 02 March 2006 09:20
 To: log4net-user@logging.apache.org
 Subject: Double configuration and SmtpAppender configuration
 
 Hi, I need some help.
 
  
 
 1) I want to configure log level for Log4net.MainForm logger 
 in the following maner:
 
  
 
 root
 
   level value=ALL /
 
 /root
 
  
 
 logger name=Log4net.MainForm
 
   level value=WARN /
 
   appender-ref ref=CustomAppender /
 
 /logger
 
 
 
 logger name=Log4net.MainForm
 
   level value=ALL /
 
   appender-ref ref=AdoNetAppender /
 
   appender-ref ref=SmtpAppender /
 
 /logger
 
  
 
  
 
 This way I want AdoNetAppender and SmtpAppender to process 
 ALL data that is passed to logger. And Only WARN and above 
 messages are handled by my CustomeAppender. Can it be 
 configured this way? 
 
  
 
 Currently the second configuration is applied, but not both.
 
  
 
 2) I have SmtpAppender configured to send messages to 
 [EMAIL PROTECTED] Now I want to configure Log4net.MainForm 
 logger to send messages to [EMAIL PROTECTED] Can I do that 
 with configuration file?
 
  
 
 Best regards,
 
 Vladimir Kovalenko
 
 


RE: RollingFileAppender thread safety

2006-03-02 Thread Nicko Cadell
log4net is thread safe as it says in the FAQ. 

How log4net implements this with regards to individual appenders is not
really important. The docs for the RollingFileAppender are correct, the
members of the type are not thread safe, but this is not relevant unless
you want to programmatically access the appender directly from you code.
During logging the appender's base class (AppenderSkeleton) ensures
serialisation of appending of logging events.

You do not need to add your own locking code around calls like:

log.Info(message);

or

LogManager.GetLogger(foo);

Cheers,
Nicko

 -Original Message-
 From: just_a_w [mailto:[EMAIL PROTECTED] 
 Sent: 02 March 2006 17:01
 To: log4net-user@logging.apache.org
 Subject: RollingFileAppender thread safety
 
 I need to use the RollingFileAppender in a multi-threaded 
 application.  The documentation is a little confusing when it 
 comes to thread safety.  The general FAQ says log4net is 
 thread-safe, but the appender's documentation says it's not.
 
 Does anyone have any suggestions on how to use the 
 RollingFileAppender in a multi-threaded application?  Do I 
 need to modify and try to compile the code myself?  Or should 
 I do something drastic, like synchronize access to the logger?
 
 Thanks.
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection 
 around http://mail.yahoo.com 
 


RE: Performance Issues - log4net with Visual Basic 2005

2006-03-02 Thread Nicko Cadell
log4net works synchronously and in general this will be the most
performant option. Appenders that talk over the network can introduce
high latencies and for these some form of asynchronous processing may be
more appropriate. 

The costs associated with an appender are not incurred if the appender
is not configured to output the event.

Cheers,
Nicko

 -Original Message-
 From: Romil Garg [mailto:[EMAIL PROTECTED] 
 Sent: 07 February 2006 22:54
 To: 'log4net-user@logging.apache.org'
 Subject: Performance Issues - log4net with Visual Basic 2005
 
 Hi,
   I am using log4net with Visual Basic 2005 and was 
 wondering if there are any performance issues with multiple 
 threads of a same process writing to 1 file. I basically have 
 a process which has a pool of 25 threads doing some 
 processing and all these threads write to the same file. Once 
 in  a while we see some methods taking a little bit longer 
 time than usual. Could it be because of file being blocked by 
 other threads. Are there any performance issues with using 
 associated with this scenario.
 We are using Console Appender, Rolling File Appender, Event 
 Log  SMTP Appenders for Warnings  Fatal Errors. 
 
 Does log4net uses threads of its own to write to the log file 
 or is it blocking the application thread to wait to write to the file.
 
 I already searched the web but could not find anything concrete. 
 
 
 
 Thanks.
 


RE: Multiple filters

2006-02-28 Thread Nicko Cadell
That is supposed to work, but due to a bug the LevelMatchFilter does not
support chaining correctly. This has been fixed in the latest source
code in subversion.
http://issues.apache.org/jira/browse/LOG4NET-29 

You can either build a new copy of log4net from the latest sources from
subversion.
http://logging.apache.org/log4net/contributing.html#svn-anon

If you want to keep using the latest log4net binary then you will need
to build your own copy of the filter in your own assembly. The updated
code for the filter is here:
http://svn.apache.org/viewcvs.cgi/logging/log4net/trunk/src/Filter/Level
MatchFilter.cs?view=markup
Just change the namespace to something appropriate, build it in one of
your assemblies, then set the type= in the config to be the assembly
qualified type name for the updated filter.

Cheers,
Nicko

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Inquisitor Jax
 Sent: 27 February 2006 13:15
 To: log4net-user@logging.apache.org
 Subject: Multiple filters
 
 I would like an appender to log everything bar 2 levels
 eg: I don't want to log ERROR and INFO level logs.
 
 What would the config look like for this?
 
 I've tried adding the following filters to the appender:
 filter type=log4net.Filter.LevelMatchFilter
   levelToMatch value=ERROR /
   acceptOnMatch value=false /
 /filter
 filter type=log4net.Filter.LevelMatchFilter
   levelToMatch value=INFO /
   acceptOnMatch value=false /
 /filter 
 
 but this only rejects ERROR.
 
 Any suggestions welcome...
 (Apologies - I've posted this same question in Please verify 
 my config file)
 
 Jax
 
 


RE: Setting AdoNetAppender parameters to null

2006-02-28 Thread Nicko Cadell
Null parameters are not supported by the AdoNetAppender in the last
release. Support has since been added to the source code.

You can either build a new copy of log4net from the latest sources from
subversion.
http://logging.apache.org/log4net/contributing.html#svn-anon

If you want to keep using the latest log4net binary then you will need
to build your own copy of the appender in your own assembly. The updated
code for the appender is here:

http://svn.apache.org/viewcvs.cgi/logging/log4net/trunk/src/Appender/Ado
NetAppender.cs?view=markup

Just change the namespace to something appropriate, build it in one of
your assemblies, then set the type= in the config to be the assembly
qualified type name for the updated appender.

Cheers,
Nicko

 -Original Message-
 From: Coates, Anthony [mailto:[EMAIL PROTECTED] 
 Sent: 28 February 2006 09:56
 To: log4net-user@logging.apache.org
 Subject: Setting AdoNetAppender parameters to null
 
 Hi
 
 I posted this previously in an earlier thread but haven't 
 received a reply yet so thought I would try it on it's own thread...
 
  
 
  
 
 I've been using properties to send several user-defined 
 messages via the ADO.NET appender. This works great except 
 when I'm trying to set a parameter value to DBNull.Value (to 
 set the column value that this parameter relates to to null), 
 e.g. using the command 
 log4net.GlobalContext.Properties[Message2] = DBNull.Value;.
 
  
 
 In this case the column in the table is being set to an empty 
 string rather than NULL. This seems to be during the call to 
 AdoNetAppender.SendBuffer when the actual ado.net parameters 
 value is being set.
 
  
 
 The config for this parameter is: 
 
  
 
 parameter 
 
 parameterName value=@message2 / 
 
 dbType value=string / 
 
 size value=100/ 
 
 layout type=log4net.Layout.PatternLayout 
 
 conversionPattern value=%property{Message2} / 
 
 /layout 
 
 /parameter 
 
  
 
 Is it possible to get it to send DBNull.Value instead so the 
 column value will be set to null? 
 
  
 
 Thanks 
 
 Ant
 
 
 
 Scanned for viruses by BlackSpider MailControl 
 http://www.blackspider.com/ . The integrity and security of 
 this message cannot be guaranteed. This email is intended for 
 the named recipient only, and may contain confidential 
 information and proprietary material. Any unauthorised use or 
 disclosure is prohibited.
 
 


RE: Question: Changing Log Settings in run time

2006-02-28 Thread Nicko Cadell
Do you want to persist the user's selection to disk so that it is
remembered the next time the application runs? If so you will need to
store that information in a user specific location. The application's
.config file is stored next to the application binary, for example under
the Program Files folder. You should not assume that the user (and
therefore the application running with the user's credentials) has
permission to write to the .config file.

You can treat the application's .config file as the starting point, load
it and then make user specific changes afterwards. You will need store
and load these changes yourself as log4net has no mechanism to export
its configuration. To programmatically change the logging levels you can
do:

log4net.ILog log = log4net.LogManager.GetLogger(my.logger.name);
log4net.Repository.Hierarchy.Logger l =
(log4net.Repository.Hierarchy.Logger)log.Logger;
l.Level = l.Hierarchy.LevelMap[INFO];

Cheers,
Nicko

 -Original Message-
 From: Oded Ouaknine [mailto:[EMAIL PROTECTED] 
 Sent: 15 February 2006 19:47
 To: log4net-user@logging.apache.org
 Subject: Question: Changing Log Settings in run time
 
 Is there a way to change the log settings after application started?
 
  
 
 Log Settings are loaded from App.Config file.
 
  
 
 I would like to change the log level according to user 
 selection while the application runs.
 
 So if he selected info and error, I will only output those.
 
  
 
 And then, once he changed that, is there a way to persist his 
 selection without manipulating the XML file myself?
 
  
 
 Thank you
 
  
 
 Oded
 
 


RE: Threshold doesn't work?

2006-02-28 Thread Nicko Cadell
You are trying to set an evaluator which is a different thing to a plain 
threshold (the differences are subtle). The FileAppender/RollingFileAppender 
does not support the evaluator at all.

Change your config to specify the threshold outside the evaluator, and then 
remove the evaluator tags completely.

If you need to understand the evaluator read the remarks section of the 
BufferingAppenderSkeleton:
http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.html

Cheers,
Nicko

 -Original Message-
 From: Jose Antonio Cortijo Solera [mailto:[EMAIL PROTECTED] 
 Sent: 14 February 2006 10:09
 To: log4net-user@logging.apache.org
 Subject: Threshold doesn't work?
 
 As I read in the FAQ I used the treshold tag to separate to 
 output of each aprender depending of a level,
 
  
 
 This is my configuration file
 
   configSections
 
 section name=log4net 
 type=log4net.Config.Log4NetConfigurationSectionHandler, log4net /
 
   /configSections
 
   log4net
 
 appender name=SmtpAppender 
 type=log4net.Appender.SmtpAppender
 
   to value=[EMAIL PROTECTED] /
 
   from value=[EMAIL PROTECTED] /
 
   subject value=TiendasOnLine - Logging /
 
   smtpHost value=10.13.1.2 /
 
   bufferSize value=32 /
 
   lossy value=true /
 
   evaluator type=log4net.Core.LevelEvaluator
 
 threshold value=ERROR/
 
   /evaluator
 
   layout type=log4net.Layout.PatternLayout
 
 conversionPattern 
 value=%newline%date [%thread] %-5level %logger 
 [%property{NDC}] - %message%newline%newline%newline /
 
   /layout
 
 /appender
 
 appender name=RollingFileAppender 
 type=log4net.Appender.RollingFileAppender 
 
   param name=File value=log\\TiendasOnLine.log /
 
   param name=AppendToFile value=true /
 
   param name=MaxSizeRollBackups value=30 /
 
   param name=MaximumFileSize value=2 /
 
   param name=RollingStyle value=Size /
 
   param name=StaticLogFileName value=true /
 
   evaluator type=log4net.spi.LevelEvaluator
 
 threshold value=DEBUG /
 
   /evaluator
 
   layout type=log4net.Layout.PatternLayout
 
 param name=ConversionPattern 
 value=%d %-5p - %m%n  /
 
   /layout
 
 /appender   
 
 appender name=TraceAppender 
 type=log4net.Appender.TraceAppender
 
   layout type=log4net.Layout.PatternLayout
 
 conversionPattern value=%date 
 [%thread] %-5level %logger [%property{NDC}] - %message%newline /
 
   /layout
 
 /appender
 
 root
 
   level value=DEBUG /
 
   appender-ref ref=SmtpAppender /
 
   appender-ref ref=RollingFileAppender /
 
 /root
 
  
 
   /log4net
 
  
 
 And in my asp.net code:
 
 . . .
 
   public class blanco : System.Web.UI.Page
 
   {
 
   
 
 private static readonly ILog log = 
 LogManager.GetLogger(typeof(blanco));
 
  
 
  
 
 private void Page_Load(object sender, System.EventArgs e)
 
 {
 
   BasicConfigurator.Configure();
 
   // Obtenemos las secciones abiertas para la 
 cadena actual
 
   log.Error(EO);
 
   log.Debug(DEBUGG);
 
 . . . . . 
 
  
 
 But the all the log is written in both appenders, in the file 
 and by email
 
  
 
 Could someone tell me what I am doing wrong?
 
  
 
 Thanks in advance.
 
 Jose Antonio Cortijo Solera
 
 Dpto. de Informática
 
 INDITEX TEMPE
 
 mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 
 Tlfno. 966657500 Ext. 40969
 
  
 
 


RE: Custom Log File Directories

2006-02-28 Thread Nicko Cadell
Russ,

While I don't have any specific suggestions can you try to recreate the
issue with log4net debugging enabled? Can you enable debugging using the
application's .config file rather than via the log4net debug=true,
for details see:
http://logging.apache.org/log4net/release/faq.html#internalDebug

If you can recreate the issue can you post the debug output generated.

Also which version of log4net are you using?

Cheers,
Nicko

 -Original Message-
 From: Russ Haley [mailto:[EMAIL PROTECTED] 
 Sent: 13 February 2006 19:42
 To: 'Log4NET User'
 Subject: Custom Log File Directories
 
 Hello all,
 
  
 
 I've been using l4n very successfully for the last 9 months 
 (holy crap, has it been that long?) with one small problem 
 pertaining to the custom directories that are created for the 
 log files. I am using custom date patterns to put log files 
 under directories named after the year and month that the log 
 files were created. So if I was to create a log file today 
 (feb 13, 2006) the file path would be as follows:
 
  
 
 root path\SYSTEM\2006\February\20060213.SYSTEM
 
  
 
 With the file being names 20060213.SYSTEM. This works for the 
 most part, but every now and then it has a bit of a hissy fit 
 and creates a folder named something like this:
 
  
 
 20060213.SYSTEM2006
 
  
 
 It seems that somehow it appends the year to the filename and 
 then creates a directory out of it and then creates the 
 directory structure under the folder noted above like so:
 
  
 
 root path\2006\February\20060213.SYSTEM2006\February\20060213.SYSTEM
 
  
 
 From what I can tell, this happens the first time I start the 
 application after a reboot or something and then corrects 
 itself after the first run. Unfortunately, it isn't a 
 consistent problem and only occurs when my boss is standing 
 over me watching what's going on. : - {
 
  
 
 Any suggestions other than locking my boss in his office (as 
 I've already been reprimanded for attempting it) would be 
 terrific.  Config settings below:
 
  
 
 Cheers!
 
 Russ
 
  
 
  
 
 log4net debug=True 
 
 appender name=SystemLog 
 type=log4net.Appender.RollingFileAppender  
 
 
 param name=Threshold 
 value=ALL /
 
 param 
 name=AppendToFile value=true /
 
 param 
 name=RollingStyle value=Date /
 
 param 
 name=MaxSizeRollBackups value=10 /
 
 param name=DatePattern 
 value=\\M\\MMdd.\S\Y\S\T\E\M/  
 
 
 param 
 name=StaticLogFileName value=False / 
   
 
 layout 
 type=log4net.Layout.PatternLayout
 
 header 
 value=[BEGIN LOGGING AT %date ]%newline 
 type=log4net.Util.PatternString /
 
 footer 
 value=[END LOGGING]%newline type=log4net.Util.PatternString /
 
 param 
 name=ConversionPattern value=%d [%t] %-5p %c [%x] - %m%n /
 
 /layout
 
 /appender
 
 
 
 root   
 
 appender-ref 
 ref=SystemEventInfoLog/

 
 /root   

 
 /log4net
 
 


RE: Flushing a buffered appender

2006-02-28 Thread Nicko Cadell
If you need to make sure that all logging events are written then call
the LogManager.Shutdown() method. This will flush everything, but you
can't log anything afterwards.

Cheers,
Nicko 

 -Original Message-
 From: Wanner, Nick [mailto:[EMAIL PROTECTED] 
 Sent: 11 February 2006 17:32
 To: log4net-user@logging.apache.org
 Subject: Flushing a buffered appender
 
 If you have an appender buffering log events, is there a 
 method to flush all the buffers and send the log events.
 One example of when I want to use this is when my application 
 closes.  I want to make sure all my log messages are output 
 before I exit.
  
 thanks,
 Nick
 


RE: Is it possible to have in the same logger different appender depending of the level?

2006-02-28 Thread Nicko Cadell
Yes you can do this by referencing both (or more) appenders from the logger and 
setting a threshold on the appender itself, for example:

appender name=ConsoleAppender type=log4net.Appender.ConsoleAppender
threshold value=INFO /
...
/appender

appender name=FileAppender type=log4net.Appender.FileAppender
threshold value=DEBUG /
...
/appender

root
appender-ref ref=ConsoleAppender /
appender-ref ref=FileAppender /
/root 

Cheers,
Nicko

 -Original Message-
 From: Jose Antonio Cortijo Solera [mailto:[EMAIL PROTECTED] 
 Sent: 10 February 2006 11:16
 To: log4net-user@logging.apache.org
 Subject: Is it possible to have in the same logger different 
 appender depending of the level?
 
 log4net-user @logging.apache.org
 
 Hi,
 
  
 
 I am pretty newbie using log4net and I would like to have for 
 a asp.net page a rolling file appender for the debug log 
 statement and other smtp appender for error logs statements.
 
 Is it possible to achieve this behaviour?
 
  
 
 Thanks in advance. 
 
  
 
 Jose Antonio Cortijo Solera
 
 Dpto. de Informática
 
 INDITEX TEMPE
 
 mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 
 Tlfno. 966657500 Ext. 40969
 
  
 
 


RE: RollingFileAppender just overwrites the same file

2006-02-28 Thread Nicko Cadell
log4net may not have permission to move the old file. If you enable
log4net internal debugging you should see any errors from log4net:

http://logging.apache.org/log4net/release/faq.html#internalDebug 

Cheers,
Nicko

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] 
 Sent: 10 February 2006 10:14
 To: log4net-user@logging.apache.org
 Subject: RollingFileAppender just overwrites the same file
 
 Hi all,
 
 Newbie question, I appreciate any advice.
 
 Below is my log4net config, copied from
 http://logging.apache.org/log4net/release/config-examples.html
 #rollingfi
 leappender
 
 It is restarting the file each day - but it's overwriting it.
 I was expecting it to rename the old one to logfile-20060209 
 or something.
 
 log4net 1.2.9 beta, debug .net framework 1.1 build.
 
 Cheers
 Iain Shepherd
 
 
 log4net
 
 appender name=RollingLogFileAppender
 type=log4net.Appender.RollingFileAppender
   file value=logfile /
   appendToFile value=true /
   rollingStyle value=Composite /
   datePattern value=MMdd /
   maxSizeRollBackups value=10 /
   maximumFileSize value=1MB /
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%date [%thread] 
 %-5level %logger [%property{NDC}] - %message%newline /
   /layout
 /appender
 
 root
   level value=ALL/
   appender-ref ref=RollingLogFileAppender/ /root
 
 /log4net
 
 
 --
 --
 For more information about Barclays Capital, please visit our 
 web site at http://www.barcap.com.
 
 
 Internet communications are not secure and therefore the 
 Barclays Group does not accept legal responsibility for the 
 contents of this message.  Although the Barclays Group 
 operates anti-virus programmes, it does not accept 
 responsibility for any damage whatsoever that is caused by 
 viruses being passed.  Any views or opinions presented are 
 solely those of the author and do not necessarily represent 
 those of the Barclays Group.  Replies to this email may be 
 monitored by the Barclays Group for operational or business reasons.
 
 --
 --
 
 


RE: Re: .NET 2.0

2006-02-24 Thread Nicko Cadell
You can use a copy of the log4net 1.2.0.9 release from
http://logging.apache.org/log4net/downloads.html.

Open Visual Studio 2005 and select File-Open-Solution, pick the
log4net.sln from the clean copy of 1.2.0.9.
Run through the conversion wizard (I don't have any issues here). Then
build a debug build.

I just did it and I get the following results:

log4net: Compile complete -- 0 errors, 120 warnings

log4net.Tests: Compile complete -- 0 errors, 47 warnings


If you want a version that builds without warnings then you will need to
use Subversion to checkout the latest copy of the sources. See
http://logging.apache.org/log4net/contributing.html#svn-anon for
details. You will need to change the Build conditional compilation
symbols from NET;NET_1_0 to NET;NET_2_0.

Cheers,
Nicko

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of LadyShug
 Sent: 24 February 2006 05:29
 To: log4net-user@logging.apache.org
 Subject: Re: .NET 2.0
 
 Great... I've been having issues during the conversion 
 process when trying to open the log4net project with visual 
 studio 2005 (.net 2.0)
 
 could you please forward me the source you used 
 
 
 
 
 
 


RE: a question about .Net 2.0 and log4net

2006-02-24 Thread Nicko Cadell
The log4net-user list is the best place to ask these questions.
http://logging.apache.org/log4net/support.html

log4net works synchronously. this means that asynchronous behaviour can
be added if required. using asynchronous behaviour to increase
performance does require some carful thinking because you need to
understand the data that needs to be captured synchronously before the
logging event can be processed asynchronously. log4net captures data
from the applications environment at the time the message is logged,
this must happen on the thread that is logging.

There is an AsyncAppender example in the latest version of the source
code in the subversion repository. 
http://svn.apache.org/viewcvs.cgi/logging/log4net/trunk/examples/net/1.0
/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?rev=31231
9view=markup

This appender can be used to wrap any other appender, for example:

appender name=AsyncSmtpAppender
type=SampleAppendersApp.Appender.AsyncAppender,SampleAppendersApp
  appender-ref ref=SmtpAppender /
/appender

The AsyncAppender receives the event synchronously, captures any
required state from the current context then queues a work item with the
ThreadPool to continue logging the event. This allows the event to be
processed asynchronously.

While this is a general approach that works for all appenders it may not
be the most efficient way of processing asynchronously for any specific
appender. If you need very low latency logging you may need to write
your own appender.

Cheers,
Nicko

 -Original Message-
 From: Ken Chu [mailto:[EMAIL PROTECTED] 
 Sent: 23 February 2006 19:33
 To: Nicko Cadell
 Subject: RE: a question about .Net 2.0 and log4net
 
 Hi Nicko,
 
 Thanks for the great explanation.
 
 I also have a question about asynchronous logging.  I 
 couldn't find any references in the mailing list archives or 
 the SDK reference about whether log4net can add log entries 
 asynchronously.  In our web application, each request will be 
 a different thread.  It would be highly desirable to have the 
 log entries appended asynchronously for better performance.  
 Is that something already built into log4net or is it 
 something I would have to add?
 
 Thanks again for your help.
 
 -Ken
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 23, 2006 10:46 AM
 To: Ken Chu
 Cc: log4net-user@logging.apache.org
 Subject: RE: a question about .Net 2.0 and log4net
 
 Ken,
 
 The http://logging.apache.org/log4net/release/framework-support.html
 page lists the frameworks that we build log4net for. We build 
 specific versions for each framework to take advantage of new 
 features that are available in new frameworks. This page 
 lists the minor differences between the builds.
 
 The log4net assemblies support binary backward compatibility. 
 The .NET 1.0 build of log4net will run fine on the .NET 1.1 
 and .NET 2.0 runtimes. There is no problem using the .NET 1.0 
 or .NET 1.1 builds of log4net with the .NET 2.0 runtime.
 
 There is a special build, the 'CLI 1.0 Compatible' build, 
 which only uses ECMA/ISO CLI 1.0 standard APIs. This build 
 runs on all the runtimes that support CLI 1.0, these include 
 all the Microsoft runtimes (except the Compact Framework) and 
 the Mono runtimes.
 
 The log4net source for the last release (1.2.0.8) builds 
 using the .NET 2.0 compilers but generates warnings due to 
 deprecated APIs and some errors in the doc comments. The 
 currently checked in source code builds cleanly using the 
 .NET 2.0 and Mono 2.0 compilers.
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Ken Chu [mailto:[EMAIL PROTECTED]
  Sent: 23 February 2006 03:56
  To: Nicko Cadell
  Subject: a question about .Net 2.0 and log4net
  
  Hi Nicko,
  
   
  
  I work at Zazzle.com, and I would like to use log4net with 
 .Net 2.0.  
  I noticed that it isn't listed as a supported framework.  
 Do you know 
  when that support will be added?
  
   
  
  Thanks,
  
  Ken Chu
  
  [EMAIL PROTECTED]
  
 
 


RE: How to have an overall ERROR level, except for one specific logger (log4net 1.2.8) ?

2006-02-24 Thread Nicko Cadell
It would be helpful if you could post your config file.

Cheers,
Nicko 

 -Original Message-
 From: Thibaut Barrère [mailto:[EMAIL PROTECTED] 
 Sent: 17 February 2006 14:30
 To: Log4NET User
 Subject: How to have an overall ERROR level, except for one 
 specific logger (log4net 1.2.8) ?
 
 Hi
 
 I feel kind of stupid - I don't manage to filter things like 
 I need: I want to have all loggers triggered above ERROR, 
 except for one logger which I'd like to trigger on INFO (I'm 
 infortunately using version 1.2.8).
 
 is it possible ?
 
 cheers
 
 Thibaut
 
 
 
 
 
 


RE: Adding appenders programmatically

2006-02-23 Thread Nicko Cadell
Yes it is possible to programmatically configure log4net. There are a
number of different ways of doing it.

1) Store your custom config in a file or stream and call one of the
log4net.Config.XmlConfigurator.Configure() methods to load the config
file.

2) Create your custom config as an in memory XML document and call the
log4net.Config.XmlConfigurator.Configure(XmlElement) method to load the
configuration.

3) Call the log4net APIs directly to set the levels and add appenders.
It helps to have some util functions:

// Set the level for a named logger
public static void SetLevel(string loggerName, string levelName)
{
  log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
  log4net.Repository.Hierarchy.Logger l =
(log4net.Repository.Hierarchy.Logger)log.Logger;

  l.Level = l.Hierarchy.LevelMap[levelName];
}

// Add an appender to a logger
public static void AddAppender(string loggerName,
log4net.Appender.IAppender appender)
{
  log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
  log4net.Repository.Hierarchy.Logger l =
(log4net.Repository.Hierarchy.Logger)log.Logger;

  l.AddAppender(appender);
}

// Find a named appender already attached to a logger
public static log4net.Appender.IAppender FindAppender(string
appenderName)
{
  foreach (log4net.Appender.IAppender appender in
log4net.LogManager.GetRepository().GetAppenders())
  {
if (appender.Name == appenderName)
{
  return appender;
}
  }
  return null;
}

In order to set the level for a logger and add an appender reference you
can then use the following calls:

SetLevel(Log4net.MainForm, ALL);
AddAppender(Log4net.MainForm, FindAppender(AdoNetAppender));

Note that the FindAppender will only find an existing appender which is
already attached to a logger. If an appender is specified in the config
file but not actually referenced by any loggers then it will be ignored.
If this is the case you will need to programmatically create the
appender as well, for example:

// Create a new file appender
public static log4net.Appender.IAppender CreateFileAppender(string name,
string fileName)
{
  log4net.Appender.FileAppender appender = new
log4net.Appender.FileAppender();
  appender.Name = name;
  appender.File = fileName;
  appender.AppendToFile = true;
  
  log4net.Layout.PatternLayout layout = new
log4net.Layout.PatternLayout();
  layout.ConversionPattern = %d [%t] %-5p %c [%x] - %m%n;
  layout.ActivateOptions();

  appender.Layout = layout;
  appender.ActivateOptions();

  return appender;
}


You can then associate it with the logger as follows:

AddAppender(Log4net.MainForm, CreateFileAppender(FileAppender,
C:\\foo.log));


Cheers,
Nicko


 -Original Message-
 From: Vladimir Kovalenko [mailto:[EMAIL PROTECTED] 
 Sent: 23 February 2006 08:33
 To: log4net-user@logging.apache.org
 Subject: Adding appenders programmatically
 
 I need to add programmatically references to appenders to a 
 specific logger. In other words I want to configure the 
 following logger from code. Is it possible?
 
  
 
 logger name=Log4net.MainForm
 
   level value=ALL /
 
   appender-ref ref=AdoNetAppender /
 
   appender-ref ref=SmtpAppender /
 
   appender-ref ref=CustomAppender /
 
 /logger
 
  
 
 Best regards,
 
 Vladimir Kovalenko
 
  
 
  
 
 


RE: SMTPAppender

2006-02-20 Thread Nicko Cadell
The built-in SmtpAppender does not support parameterise the subject
line. There is an example appender in the 1.2.9 release that does:
SimpleSmtpAppender. You can find the source for it at

log4net-1_2_9\examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appen
der 

This appender does not buffer events before sending them as the
SmtpAppender does. SimpleSmtpAppender just sends each event in a
separate email, but it does allow the subject to be generated by a
PatternLayout.

To use this appender you will need to compile the SimpleSmtpAppender
class yourself either in a separate dll or as part of your application.

Cheers,
Nicko

 -Original Message-
 From: Fahad Sarwar [mailto:[EMAIL PROTECTED] 
 Sent: 20 February 2006 11:18
 To: log4net-user@logging.apache.org
 Subject: SMTPAppender
 
 Hi All,
  
 Jsut a quick query.  When sending email log messages, using 
 the SMTP Appender, the Subject is always constant (defined in 
 the config file).  Is it possible to send a different Subject 
 out depending on the message ie if i log at INFO level, send 
 one subject header and for an ERROR log send a different 
 subject header.
  
 regards
  
 
 Fahad Sarwar
 
 Opal Telecom
 
 Applications Team
 
 Irlam
 
 Tel: +44 161 222 2145
 
 Fax: +44 161 222 2008
 
 Email: [EMAIL PROTECTED] 
 
  
 
 This communication together with any attachments transmitted 
 with it (this E-Mail) is intended only for the use of the 
 addressee and may contain information which is privileged and 
 confidential. If the reader of this E-Mail is not the 
 intended recipient or the employee or agent responsible for 
 delivering it to the intended recipient you are hereby 
 notified that any use, dissemination, forwarding, printing or 
 copying of this E-Mail is strictly prohibited. Addressees 
 should check this E-mail for viruses. The Company makes no 
 representations as regards the absence of viruses in this 
 E-Mail. If you have received this E-Mail in error please 
 notify our IT Support Team immediately by telephone on 0845 
 456 9100 or via e-mail at [EMAIL PROTECTED] Please 
 then immediately delete, erase or otherwise destroy this 
 E-Mail and any copies of it.
 
 Any opinions expressed in this E-Mail are those of the author 
 and do not necessarily constitute the views of the Company. 
 Nothing in this E-Mail shall bind the Company in any contract 
 or obligation.
 
 For the purposes of this E-Mail the Company means Opal 
 Telecom Ltd.  Please feel free to visit our website: 
 www.opaltelecom.co.uk http://www.opaltelecom.co.uk/ 
 
 Opal Telecom Ltd (Registered in England  Wales No. 3849133) 
 
 Brinell Drive, Northbank Industrial Park, Irlam, Manchester M44 5BL.
 
 A member of the Carphone Warehouse Group of Companies
 
  
 


RE: SMTPAppender

2006-02-20 Thread Nicko Cadell
Neither of the email appenders I know of send attachments, however the
SimpleSmtpAppender could easily be modified to add attachments to the
mail. The question would be what to include in the attachment and how to
configure it all.

Cheers,
Nicko

 -Original Message-
 From: Fahad Sarwar [mailto:[EMAIL PROTECTED] 
 Sent: 20 February 2006 12:19
 To: 'Log4NET User'
 Subject: RE: SMTPAppender
 
 That's great.  Thanks.
 
 Do you know if there is an appender which would allow you to 
 send Attachments with each email that is generated. 
 
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: 20 February 2006 12:11
 To: Log4NET User
 Subject: RE: SMTPAppender
 
 The built-in SmtpAppender does not support parameterise the 
 subject line.
 There is an example appender in the 1.2.9 release that does:
 SimpleSmtpAppender. You can find the source for it at
 
 log4net-1_2_9\examples\net\1.0\Appenders\SampleAppendersApp\cs
 \src\Appen
 der 
 
 This appender does not buffer events before sending them as 
 the SmtpAppender does. SimpleSmtpAppender just sends each 
 event in a separate email, but it does allow the subject to 
 be generated by a PatternLayout.
 
 To use this appender you will need to compile the 
 SimpleSmtpAppender class yourself either in a separate dll or 
 as part of your application.
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Fahad Sarwar [mailto:[EMAIL PROTECTED]
  Sent: 20 February 2006 11:18
  To: log4net-user@logging.apache.org
  Subject: SMTPAppender
  
  Hi All,
   
  Jsut a quick query.  When sending email log messages, using 
 the SMTP 
  Appender, the Subject is always constant (defined in the 
 config file).
  Is it possible to send a different Subject out depending on the 
  message ie if i log at INFO level, send one subject header 
 and for an 
  ERROR log send a different subject header.
   
  regards
   
  
  Fahad Sarwar
  
  Opal Telecom
  
  Applications Team
  
  Irlam
  
  Tel: +44 161 222 2145
  
  Fax: +44 161 222 2008
  
  Email: [EMAIL PROTECTED]
  
   
  
  This communication together with any attachments 
 transmitted with it 
  (this E-Mail) is intended only for the use of the 
 addressee and may 
  contain information which is privileged and confidential. If the 
  reader of this E-Mail is not the intended recipient or the 
 employee or 
  agent responsible for delivering it to the intended 
 recipient you are 
  hereby notified that any use, dissemination, forwarding, 
 printing or 
  copying of this E-Mail is strictly prohibited. Addressees 
 should check 
  this E-mail for viruses. The Company makes no representations as 
  regards the absence of viruses in this E-Mail. If you have received 
  this E-Mail in error please notify our IT Support Team 
 immediately by 
  telephone on 0845
  456 9100 or via e-mail at [EMAIL PROTECTED] Please then 
  immediately delete, erase or otherwise destroy this E-Mail and any 
  copies of it.
  
  Any opinions expressed in this E-Mail are those of the 
 author and do 
  not necessarily constitute the views of the Company.
  Nothing in this E-Mail shall bind the Company in any contract or 
  obligation.
  
  For the purposes of this E-Mail the Company means Opal 
 Telecom Ltd.  
  Please feel free to visit our website:
  www.opaltelecom.co.uk http://www.opaltelecom.co.uk/
  
  Opal Telecom Ltd (Registered in England  Wales No. 3849133)
  
  Brinell Drive, Northbank Industrial Park, Irlam, Manchester M44 5BL.
  
  A member of the Carphone Warehouse Group of Companies
  
   
  
 
 


RE: Unhandled exception!

2006-02-20 Thread Nicko Cadell
When log4net loads config file via the XmlConfiguratorAttribute it
always opens the file directly itself. It therefore needs to know where
the application is deployed. This is known as path discovery and
requires a specific CAS permission.

If the application is hosted on a local drive or a network share the
configurator needs to have the PathDiscovery FileIOPermission in order
to find the config file relative to the application base directory.

CAS permissions are granted via the security configuration of the .NET
runtime. Permissions are layered to allow them to be specified on a
user, machine or enterprise basis. By default locally deployed
applications will have PathDiscovery permission.

If you cannot grant your application the PathDiscovery permission you
must load the configuration from the application's .config file by
calling the log4net.Config.XmlConfigurator.Configure() method
programmatically. Remove any XmlConfiguratorAttribute you have specified
and add a call to XmlConfigurator.Configure() as early as possible in
your application start-up.

Cheers,
Nicko

 -Original Message-
 From: Morten Andersen [mailto:[EMAIL PROTECTED] 
 Sent: 01 February 2006 11:39
 To: log4net-dev@logging.apache.org; Log4NET User
 Subject: Unhandled exception!
 
 
 /Security Exception/
 
 *Description: *The application attempted to perform an 
 operation not allowed by the security policy.  To grant this 
 application the required permission please contact your 
 system administrator or change the application's trust level 
 in the configuration file.
 
 *Exception Details: *System.Security.SecurityException: 
 Request for the permission of type 
 'System.Security.Permissions.FileIOPermission,
 mscorlib, Version=2.0.0.0, Culture=neutral, 
 PublicKeyToken=b77a5c561934e089' failed.
 
 Line 78: this.log = log4net.LogManager.GetLogger(logfilename);
 
 ||
 
 [SecurityException: Request for the permission of type 
 'System.Security.Permissions.FileIOPermission, mscorlib, 
 Version=2.0.0.0, Culture=neutral, 
 PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object 
 demand, StackCrawlMark stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.AppDomainSetup.VerifyDir(String dir, Boolean normalize) +110
System.AppDomain.get_BaseDirectory() +61
log4net.Util.SystemInfo.get_ApplicationBaseDirectory() +31
log4net.Config.XmlConfiguratorAttribute.Configure(Assembly 
 sourceAssembly, ILoggerRepository targetRepository) +30

 log4net.Core.DefaultRepositorySelector.ConfigureRepository(Ass
 embly assembly, ILoggerRepository repository) +314

 log4net.Core.DefaultRepositorySelector.CreateRepository(Assemb
 ly repositoryAssembly, Type repositoryType, String 
 repositoryName, Boolean readAssemblyAttributes) +532

 log4net.Core.DefaultRepositorySelector.CreateRepository(Assemb
 ly repositoryAssembly, Type repositoryType) +42

 log4net.Core.DefaultRepositorySelector.GetRepository(Assembly 
 repositoryAssembly) +80
log4net.Core.LoggerManager.GetLogger(Assembly 
 repositoryAssembly, String name) +132
log4net.LogManager.GetLogger(Assembly repositoryAssembly, 
 String name) +30
log4net.LogManager.GetLogger(String name) +34
   
 
 
 -- 
 
 Best Regards
 *Morten Andersen*
 Developer
 Vianett AS http://www.vianett.no/ | [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] | Office: +47 69 20 69 74 
 callto://+4769206974 | Skype: mortander callto://mortander
 
 


RE: Unhandled exception!

2006-02-20 Thread Nicko Cadell
No, log4net should just fail to locate and load the config file. I will
checkin a fix for this.

Cheers,
Nicko

 -Original Message-
 From: Morten Andersen [mailto:[EMAIL PROTECTED] 
 Sent: 20 February 2006 17:10
 To: Log4NET User
 Subject: Re: Unhandled exception!
 
 Should it be possible for log4net to take a whole site down 
 because of an exception like this?
 
 Best Regards
 *Morten Andersen*
 Developer
 Vianett AS http://www.vianett.no/ | [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] | Office: +47 69 20 69 74 
 callto://+4769206974 | Skype: mortander callto://mortander
 
 
 
 Nicko Cadell wrote:
  When log4net loads config file via the XmlConfiguratorAttribute it 
  always opens the file directly itself. It therefore needs to know 
  where the application is deployed. This is known as path 
 discovery and 
  requires a specific CAS permission.
 
  If the application is hosted on a local drive or a network 
 share the 
  configurator needs to have the PathDiscovery 
 FileIOPermission in order 
  to find the config file relative to the application base directory.
 
  CAS permissions are granted via the security configuration 
 of the .NET 
  runtime. Permissions are layered to allow them to be specified on a 
  user, machine or enterprise basis. By default locally deployed 
  applications will have PathDiscovery permission.
 
  If you cannot grant your application the PathDiscovery 
 permission you 
  must load the configuration from the application's .config file by 
  calling the log4net.Config.XmlConfigurator.Configure() method 
  programmatically. Remove any XmlConfiguratorAttribute you have 
  specified and add a call to XmlConfigurator.Configure() as early as 
  possible in your application start-up.
 
  Cheers,
  Nicko
 

  -Original Message-
  From: Morten Andersen [mailto:[EMAIL PROTECTED]
  Sent: 01 February 2006 11:39
  To: log4net-dev@logging.apache.org; Log4NET User
  Subject: Unhandled exception!
 
 
  /Security Exception/
 
  *Description: *The application attempted to perform an 
 operation not 
  allowed by the security policy.  To grant this application the 
  required permission please contact your system administrator or 
  change the application's trust level in the configuration file.
 
  *Exception Details: *System.Security.SecurityException: 
  Request for the permission of type
  'System.Security.Permissions.FileIOPermission,
  mscorlib, Version=2.0.0.0, Culture=neutral, 
  PublicKeyToken=b77a5c561934e089' failed.
 
  Line 78: this.log = log4net.LogManager.GetLogger(logfilename);
 
  ||
 
  [SecurityException: Request for the permission of type 
  'System.Security.Permissions.FileIOPermission, mscorlib, 
  Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 
  failed.]
 System.Security.CodeAccessSecurityEngine.Check(Object
  demand, StackCrawlMark stackMark, Boolean isPermSet) +0
 System.Security.CodeAccessPermission.Demand() +59
 System.AppDomainSetup.VerifyDir(String dir, Boolean 
 normalize) +110
 System.AppDomain.get_BaseDirectory() +61
 log4net.Util.SystemInfo.get_ApplicationBaseDirectory() +31
 log4net.Config.XmlConfiguratorAttribute.Configure(Assembly
  sourceAssembly, ILoggerRepository targetRepository) +30
 
  log4net.Core.DefaultRepositorySelector.ConfigureRepository(Ass
  embly assembly, ILoggerRepository repository) +314
 
  log4net.Core.DefaultRepositorySelector.CreateRepository(Assemb
  ly repositoryAssembly, Type repositoryType, String repositoryName, 
  Boolean readAssemblyAttributes) +532
 
  log4net.Core.DefaultRepositorySelector.CreateRepository(Assemb
  ly repositoryAssembly, Type repositoryType) +42
 
  log4net.Core.DefaultRepositorySelector.GetRepository(Assembly
  repositoryAssembly) +80
 log4net.Core.LoggerManager.GetLogger(Assembly
  repositoryAssembly, String name) +132
 log4net.LogManager.GetLogger(Assembly 
 repositoryAssembly, String 
  name) +30
 log4net.LogManager.GetLogger(String name) +34

 
 
  --
 
  Best Regards
  *Morten Andersen*
  Developer
  Vianett AS http://www.vianett.no/ | [EMAIL PROTECTED] 
  mailto:[EMAIL PROTECTED] | Office: +47 69 20 69 74 
  callto://+4769206974 | Skype: mortander callto://mortander
 
 
  
 

 


RE: Strange behavior using Log4Net and NUnit

2005-12-23 Thread Nicko Cadell
Have you tried copying the Tadas.Persistence.Framework.Common.DLL dll
into the C:\Program Files\NUnit 2.2\bin folder? Does this fix the
problem? If so then it is just a .net loader problem.

Nicko

 -Original Message-
 From: Jan Luc Heide, ter [mailto:[EMAIL PROTECTED] 
 Sent: 23 December 2005 08:28
 To: log4net-user@logging.apache.org
 Subject: Strange behavior using Log4Net and NUnit
 
 Hi,
 
 When testing my application from NUnit, with logging set to 
 DEBUG I get the folowing (attached) output in NUnit and 
 logging in the log file.
 I also include the configuration file.
 When NOT using NUnit it works fine.
 
 The last error (no transaction) is weird because 
 serialization seems to work half (GetData is called, but the 
 deserializing constructor is not). 
 Could this be associated with the Log4net error?
 
 We use the 1.2.0 bea 8 version.
 
 Thanks for any help.
 jlh.
 
 Met vriendelijke groet,
 The Anglo Dutch Assurance Society
 
 
 Jan Luc ter Heide
 Programmeur
 
 Dick Ketlaan 6-10, 1687 CD Wognum
 Postbus 70
 1687 ZH Wognum
 Telefoon  +31 (0) 229 577 265
 Fax +31 (0) 229 577 269
 [EMAIL PROTECTED] 
 
 
 ###
 
 * * *   D I S C L A I M E R   * * *
 
 ###
 
 De informatie in dit e-mailbericht is vertrouwelijk en 
 uitsluitend bestemd voor de geadresseerde. Wanneer u dit 
 bericht per abuis ontvangt, gelieve onmiddellijk contact op 
 te nemen met de afzender per kerende e-mail. Wij verzoeken u 
 dit e-mailbericht te vernietigen en de inhoud ervan aan 
 niemand openbaar te maken. Afzender aanvaardt geen enkele 
 aansprakelijkheid voor onjuiste, onvolledige dan wel 
 ontijdige overbrenging van de inhoud van een verzonden 
 e-mailbericht, noch voor door haar daarbij overgebrachte virussen.
 
 The information contained in this e-mail is confidential and 
 may be privileged. It may be read, copied and used only by 
 the intended recipient. If you have received it in error, 
 please contact the sender immediately by return e-mail. 
 Please delete this e-mail and do not disclose its contents to 
 any person. Sender does not accept any liability for any 
 errors, omissions, delays of receipt or viruses in the 
 contents of this message which arise as a result of e-mail 
 transmission.
 


RE: Log4net does not works in production env

2005-12-23 Thread Nicko Cadell
Do you get any output if you enable internal log4net debug and use the
sysinternals debugview?
http://logging.apache.org/log4net/release/faq.html#internalDebug
 
Cheers,
Nicko

 -Original Message-
 From: S. K Rahman [mailto:[EMAIL PROTECTED] 
 Sent: 23 December 2005 14:41
 To: log4net-user@logging.apache.org
 Subject: Log4net does not works in production env
 
 Hello all,
 
 I am facing a strange problem.
 The problem seems exactly like somebody posted earlier
 
 -
 Logging is working fine on my dev machine but when I deploy 
 it does not do anything. I copied  the whole code on the 
 production machine and tried debugging it, it worked fine, I 
 go the logs.
 -
 http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4net-us
 [EMAIL PROTECTED]msgId=1605998
 
 I have enabled the log4net debug but it does not seems to 
 work as well. So I tried building log4net again in the 
 production server and used the binaries from build, but it 
 does not work either.
 
 I am not sure how can I debug the problem. I tought that 
 problem to be permission related but it's not the case also 
 if I use process explorer from systeinternals.com I can see 
 the log4net dll loaded by w3wp.exe where as in my development 
 machine it is  aspnet_wp.exe My development machine is XP 
 where as production is Windows 2003.
 
 I am trying to d log.debug(my message) from the asp.net code.
 
 Here is the my log4net config and web.config
 
 -
 ?xml version=1.0 encoding=utf-8 ?
 log4net debug=true
   appender name=LogFileAppender 
 type=log4net.Appender.FileAppender 
   file value=mylog.Log /
   appendToFile value=true /
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%date 
 [%thread] %-5level %logger [%ndc] - %message%newline /
   /layout
   /appender
   appender name=HttpTraceAppender
 type=log4net.Appender.AspNetTraceAppender 
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%date 
 [%thread] %-5level %logger [%ndc] - %message%newline /
   /layout
   /appender
   appender name=SmtpAppender 
 type=log4net.Appender.SmtpAppender
   to value=[EMAIL PROTECTED] /
   from value=[EMAIL PROTECTED] /
   subject value=Logger message /
   smtpHost value=plex /
   bufferSize value=512 /
   lossy value=true /
   evaluator type=log4net.Core.LevelEvaluator
   threshold value=DEBUG/
   /evaluator
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%newline%date 
 [%thread] %-5level %logger [%property{NDC}] - 
 %message%newline%newline%newline /
   /layout
   /appender
   appender name=RollingLogFileAppender
 type=log4net.Appender.RollingFileAppender
   file value=CustomLogs\CustomLogs.log /
   appendToFile value=true /
   datePattern value=MMdd /
   rollingStyle value=Date /
   maxSizeRollBackups value=10 /
   maximumFileSize value=5MB /
   rollingStyle value=Size /
   staticLogFileName value=true /
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%date 
 [%thread] %-5level %logger [%ndc] - %message%newline /
   /layout
   /appender
   root
   level value=DEBUG /
   appender-ref ref=LogFileAppender /
   appender-ref ref=HttpTraceAppender /
   appender-ref ref=SmtpAppender /
   !-- appender-ref ref=RollingLogFileAppender / --
   appender-ref ref=RollingLogFileAppender /
   /root
 /log4net
 -
 
 -
 ?xml version=1.0 encoding=utf-8 ?
 configuration
 
   system.web
 
 !--  DYNAMIC DEBUG COMPILATION
   Set compilation debug=true to enable ASPX debugging. 
 Otherwise, setting this value to
   false will improve runtime performance of this application.
   Set compilation debug=true to insert debugging 
 symbols (.pdb information)
   into the compiled page. Because this creates a 
 larger file that executes
   more slowly, you should set this value to true only 
 when debugging and to
   false at all other times. For more information, 
 refer to the documentation about
   debugging ASP.NET files.
 --
 compilation
  defaultLanguage=c#
  debug=true
 /
 
 !--  CUSTOM ERROR MESSAGES
   Set customErrors mode=On or RemoteOnly to 
 enable custom error messages, Off to disable.
   Add error tags for each of the errors you want to handle.
 
   On Always display custom (friendly) messages.
   Off Always display detailed ASP.NET error information.
   RemoteOnly Display custom 

RE: Log4net does not works in production env

2005-12-23 Thread Nicko Cadell
What is the identity for the IIS6 Application Pool for your site? Have
you given this identity the correct permissions? By default it is the
Network Service account.

Nicko

 -Original Message-
 From: S. K Rahman [mailto:[EMAIL PROTECTED] 
 Sent: 23 December 2005 15:01
 To: Log4NET User
 Subject: Re: Log4net does not works in production env
 
 On 12/23/05, Nicko Cadell [EMAIL PROTECTED] wrote:
  Do you get any output if you enable internal log4net debug 
 and use the 
  sysinternals debugview?
  http://logging.apache.org/log4net/release/faq.html#internalDebug
 
 
 I did enabled debugging  but I was not sure how view. I 
 downloaded debugview and indeed I got the output.
 As for the log it seems to be issue with the permission but I 
 have given aspnet account/ IUSR account and other accounts 
 full rights to that app folder as well as the log file.
 
 Here is the text
 
 [2956] log4net: FileAppender: Opening file for writing 
 [E:\www\l4n\mylog.Log] append [True] [2956] log4net:ERROR 
 [FileAppender] Unable to acquire lock on file 
 E:\www\l4n\mylog.Log. Access to the path 
 E:\www\l4n\mylog.Log is denied.
 [2956] log4net:ERROR [FileAppender]
 OpenFile(E:\www\l4n\mylog.Log,True) call failed.
 [2956] LockStateException: The file is not currently locked
 [2956]at log4net.Appender.LockingStream.AssertLocked()
 [2956]at log4net.Appender.LockingStream.get_CanWrite()
 [2956]at System.IO.StreamWriter..ctor(Stream stream, Encoding
 encoding, Int32 bufferSize)
 [2956]at System.IO.StreamWriter..ctor(Stream stream, 
 Encoding encoding)
 [2956]at log4net.Appender.FileAppender.OpenFile(String fileName,
 Boolean append)
 [2956]at log4net.Appender.FileAppender.SafeOpenFile(String
 fileName, Boolean append)
 [2956] log4net:ERROR [FileAppender] No output stream or file 
 set for the appender named [LogFileAppender].
 [2956] log4net:ERROR [SmtpAppender] Error occurred while 
 sending e-mail notification.
 [2956] System.Web.HttpException: Could not access 'CDO.Message'
 object. --- System.Reflection.TargetInvocationException: 
 Exception has been thrown by the target of an invocation. 
 --- System.Runtime.InteropServices.COMException 
 (0x8004020F): The server rejected one or more recipient 
 addresses. The server response was: 550
 5.7.1 Unable to relay [EMAIL PROTECTED] [2956]
 [2956]--- End of inner exception stack trace ---
 [2956]at System.RuntimeType.InvokeDispMethod(String name,
 BindingFlags invokeAttr, Object target, Object[] args, 
 Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
 [2956]at System.RuntimeType.InvokeMember(String name, BindingFlags
 invokeAttr, Binder binder, Object target, Object[] args, 
 ParameterModifier[] modifiers, CultureInfo culture, String[]
 namedParameters)
 [2956]at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object
 obj, String methodName, Object[] args)
 [2956]--- End of inner exception stack trace ---
 [2956]at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object
 obj, String methodName, Object[] args)
 [2956]at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
 [2956]at System.Web.Mail.SmtpMail.Send(MailMessage message)
 [2956]at 
 log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)
 [2956] log4net: FileAppender: Opening file for writing 
 [E:\www\l4n\Logs\mylog.Log] append [True] [2956] 
 log4net:ERROR [RollingFileAppender] Unable to acquire lock on 
 file E:\www\l4n\Logs\mylog.Log. Access to the path 
 E:\plexwww\l4n\PMSLogs\PMSlog.log is denied.
 [2956] log4net:ERROR [RollingFileAppender]
 OpenFile(E:\www\l4n\Logs\mylog.Log,True) call failed.
 [2956] LockStateException: The file is not currently locked
 [2956]at log4net.Appender.LockingStream.AssertLocked()
 [2956]at log4net.Appender.LockingStream.get_CanWrite()
 [2956]at System.IO.StreamWriter..ctor(Stream stream, Encoding
 encoding, Int32 bufferSize)
 [2956]at System.IO.StreamWriter..ctor(Stream stream, 
 Encoding encoding)
 [2956]at log4net.Appender.FileAppender.OpenFile(String fileName,
 Boolean append)
 [2956]at log4net.Appender.RollingFileAppender.OpenFile(String
 fileName, Boolean append)
 [2956]at log4net.Appender.FileAppender.SafeOpenFile(String
 fileName, Boolean append)
 [2956] log4net:ERROR [RollingFileAppender] No output stream 
 or file set for the appender named [RollingLogFileAppender].
 [384] EVENT=heartbeat;INTERVAL=30;MN_KEY_SEQ=ctrl+alt+f1;
 [384] 
 EVENT=update;MACADDR=:00:0d:56:bb:88:15;CRYPT=:0e:87:ef:29:e
 8:c6:10:82;
 [1324] ASPI Polling Devices
 [1324] ASPIPro PollBus
 [1324] ASPIPro PollBus
 


RE: BUG? Parent appenders log based on child appender level

2005-12-21 Thread Nicko Cadell
There are various different ways to arrange this sort of logging
depending if you only want the INFO message from a single class (or
logger subtree). 
One way to achieve the result is using the threshold:


log4net
appender name=smtpAppender
type=log4net.Appender.HtmlSmtpAppender
threshold value=ERROR /
to value= [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  /
from value=[EMAIL PROTECTED] /
subject value=Application Error /
smtpHost value=somesmtpserver.com /
/appender
appender name=rollingFileAppender
type=log4net.Appender.RollingFileAppender  
file value=Application.log /
RollingStyle value=Date /
datePattern value=MMdd /
layout type= log4net.Layout.PatternLayout
conversionPattern value=%newline%date %-4timestamp
[%thread] %-5level %logger %ndc - %message%newline /
/layout
/appender 

!-- Set root logger level to DEBUG and its only appender to A1
--
root
level value=ERROR /
appender-ref ref=smtpAppender / 
appender-ref ref=rollingFileAppender /
/root
logger name=MyNamespace.MyClass
level value=INFO /
/logger 
/log4net 


The threshold value=ERROR / on the smtpAppender limits the events
that are sent via the appender to only ERROR and above. The 2 appenders
are attached to the root logger, this means that all errors will also
be logged to the rollingFileAppender as well as the smtpAppender.

Cheers,
Nicko

 -Original Message-
 From: Mike Raath [mailto:[EMAIL PROTECTED] 
 Sent: 21 December 2005 09:04
 To: log4net-user@logging.apache.org
 Subject: BUG? Parent appenders log based on child appender level
 
 I've got a requirement where I need one appender to log info 
 level messages to a log file, which I've defined as a 
 RollingFileAppender, and error messages to a mail, which is 
 an appender I've written myself called HtmlSmtpAppender (see 
 my earlier post regarding html format mails). 
 
 The config entry looks like this:
 
 log4net
 appender name=smtpAppender 
 type=log4net.Appender.HtmlSmtpAppender
 to value= [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED]  /
 from value=[EMAIL PROTECTED] /
 subject value=Application Error /
 smtpHost value=somesmtpserver.com /
 /appender
 appender name=rollingFileAppender 
 type=log4net.Appender.RollingFileAppender  
 file value=Application.log /
 RollingStyle value=Date /
 datePattern value=MMdd /
 layout type= log4net.Layout.PatternLayout
 conversionPattern value=%newline%date 
 %-4timestamp [%thread] %-5level %logger %ndc - %message%newline /
 /layout
 /appender 
 
 !-- Set root logger level to DEBUG and its only 
 appender to A1 --
 root
 level value=ERROR /
 appender-ref ref=smtpAppender / 
 /root
 logger name=MyNamespace.MyClass
 level value=INFO /
 appender-ref ref=rollingFileAppender /
 /logger 
 /log4net
 
 
 
 Now what I've noticed is that when an INFO event is logged, 
 the MyNameSpace.MyClass Logger is tested against the defined 
 log level and correctly called. However, when the appender 
 hierarchy is iterated, and we get to the root logger, its 
 append is called even though it has a level set to error. 
 
 Is this an error in my understanding of how the hierarchy is 
 used, or is it a bug? I wanted a catch-all error logger but 
 obviously I can achieve what I want as things currently stand 
 by defining a root debug logger and a class (or parent 
 namespce) logger which logs error events. 
 
 Regards,
 Mike
 
 


RE: Re: SmtpAppender configuration error

2005-12-16 Thread Nicko Cadell
The error message regarding relaying would seem to indicate a mail
server setup problem rather than an issue connecting with the server.
Are you sure that your local server is setup to allow relaying for the
domains of the email address your are sending from (i.e. pretending to
be). 

The main issue with the System.Web.Mail library is that the SmtpHost
property is global. If the application sets the SmtpHost independent of
log4net then log4net should not reset it unless told to use a specific
value. log4net treats the empty string as unset and therefore does not
overwrite the global value of the SmtpHost.

If you need a different behaviour then you can just subclass the
SmtpAppender and override the ActivateOptions method to set the SmtpHost
property.

Cheers,
Nicko

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of TomekR
 Sent: 16 December 2005 08:18
 To: log4net-user@logging.apache.org
 Subject: Re: SmtpAppender configuration error
 
 Nicko !
 
 Thanks for response.
 Your way almost :-) worked.
 Look at the extract of my log:
 
 log4net: SmtpHost: [BSPDEVSERVER]
 log4net: SmtpMail.SmtpServer: [BSPDEVSERVER] log4net:ERROR 
 2005-12-16 08:25:53  Error occurred while sending e-mail notification.
 System.Web.HttpException: Could not access 'CDO.Message' object. ---
 System.Reflection.TargetInvocationException: Exception has 
 been thrown by the target of an invocation. --- 
 System.Runtime.InteropServices.COMException
 (0x8004020F): The server rejected one or more recipient 
 addresses. The server response was: 550 5.7.1 Unable to relay for xxx
 -
 (the square brackets are not the part of the value - they 
 only surround the value).
 
 Instead of xxx the real address was logged. The address was 
 valid - it's my address and it works with other server. 
 It seems to be SmtpMail problem, that it can't work with 
 machine name as smtp server name. I've checked, that with 
 such a setting SmtpMail is able to serve mail only to locally 
 defined (on the machine with local smtp) user names.
 Do you have other suggestions ?
 
 Cheers,
 --
   Tomek
 
 


RE: html output

2005-12-15 Thread Nicko Cadell
Mike,

The changes to allow property values to be specified in the text node of
the config element are only available in the SVN head of log4net. You
will need to pass the text in the value= attribute. You will need to
use appropriate XML encoding for the  and  chars.

Cheers,
Nicko

 -Original Message-
 From: Mike Raath [mailto:[EMAIL PROTECTED] 
 Sent: 15 December 2005 09:12
 To: log4net-user@logging.apache.org
 Subject: Re: html output
 
 Hi there. I've been trying to get this to work too, and 
 stumbled across Ron's suggestion
 
 This may work for very simple cases:
 
  layout type=log4net.Layout.PatternLayout
   conversionPattern
 
![[CDATA[
 table
  tr
   tdstrong%level/strong/td
   td%date/td
   td%message/td
  /tr
 
 /table
]]
   /conversionPattern
  /layout
 
 However Log4Net complains about this method of specifying a 
 pattern - seems the pattern can't be defined in the inner 
 html; that it must be in the value attribute of the 
 conversionPattern tag. (Also I presume the ![[CDATA is a type). 
 
 Is that correct? Or if you can declare the pattern using 
 CDATA please could someone advise?
 
 Many thanks for any help you can give. I'm using Log4Net version 1.2.9
 
 Mike
 
 


RE: SmtpAppender configuration error

2005-12-15 Thread Nicko Cadell
You could set the SMTP host name to the name of the local computer
rather than empty string

SmptHost value=${COMPUTERNAME} /

Cheers,
Nicko

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of TomekR
 Sent: 15 December 2005 16:32
 To: log4net-user@logging.apache.org
 Subject: SmtpAppender configuration error
 
 Hello !
 
 (I've browsed this list to avoid duplicate threads, but if 
 this problem was already announced then forgive me).
 Let imagine following scenario: 
 
 1.
 my app uses smpt appender, which is configured using 
 ConfigureAndWatch. 
 Initially the property smtpHost is set to MyMailServer.net.
 
 Some log events occured so some e-mails was sent, what 
 results, that SmtpMail.SmtpServer is set to MyMailServer.net
 
 2.
 Then user changes mail server and sets empty string with 
 intention to use local smtp server.
 The appender reloads configuration and sets its property to 
 empty string.
 BUT the emails are sent directed to previous mail server !!! 
 Why ? Becouse of
 that:
 (ending part of SendBuffer method)
 
 if (m_smtpHost != null  m_smtpHost.Length  0) {
   SmtpMail.SmtpServer = m_smtpHost;
 }
 
 Since appender property i.e. smtpHost is empty, then if 
 condition prevents change of SmtpServer property.
 IMO, this setting should be done unconditionally.
 
 Regards,
 --
 Tomek
 
 


RE: Programatically changing the logger for NHibernate

2005-12-13 Thread Nicko Cadell
Philip,

Rather than use a Filter, there is a more performant option, which is to
set the level on the NHibernate logger. By default this will be
inherited by the child loggers, i.e. all of the NHibernate loggers. To
do this in code you can do:

((log4net.Repository.Hierarchy.Logger)LogManager.GetLogger(NHibernate)
.Logger).Level = Level.Off;

While there are advantages to configuring log4net programmatically this
sort of logger hierarchy is much easier to see in the XML config file.

Cheers,
Nicko

 -Original Message-
 From: Philip Nelson [mailto:[EMAIL PROTECTED] 
 Sent: 28 November 2005 16:57
 To: Log4NET User
 Subject: Re: Programatically changing the logger for NHibernate
 
 And this did the trick. I tried to use the PropertyFilter 
 directly, but I couldn't come up with the property key that 
 represented LoggerName. I tried loggername, LoggerName, 
 logger, Logger, log4net:logger and log4net:loggername
 
 class NHibernateFilter : StringMatchFilter {
 public override FilterDecision Decide(LoggingEvent loggingEvent)
 {
 FilterDecision decision = FilterDecision.Accept;
 if (loggingEvent.LoggerName.StartsWith(NHibernate))
 decision = FilterDecision.Deny;
   
 return decision;
 }
 
 }
 
 Thanks for your help!
 
 --- Philip Nelson [EMAIL PROTECTED] wrote:
 
  I'll look into it, thanks.
  
  --- [EMAIL PROTECTED] wrote:
  
   I would think that you could set up a filter to exclude the 
   NHibernate logs.  Looking at the code however implies 
 that you might 
   have to write a not assembly filter.
   
   
   
   
 
  
Philip Nelson
  
[EMAIL PROTECTED]
  
.com
   To 
  Log4NET User   
  
11/28/2005 08:40  
 log4net-user@logging.apache.org   
AM   
   cc 
 
  
 
  Subject 
Please respond to Re: 
 Programatically changing the
 Log4NET User   logger for 
 NHibernate   
[EMAIL PROTECTED]
  
ging.apache.org 
  
 
  
 
  
 
  
 
  
   
   
   
   
   Since replies have been light, and my reply to why not use xml 
   configuration
   might have been a little abrupt, let me elaborate.
   
   I have been a log4net user almost since the first release. I have 
   evangelized using it for the whole time, just like I evangelized 
   log4j to my java clients before that. The tool is just 
 what I want 
   and has been really useful to me.
   I
   hope my last post didn't lead you to think I'm anti xml or 
   something. I think I'm still listed on the JDOM JSR expert group, 
   and have accepted patches in both the crimson and xerces parsers.
   
   My original reason for trying this was because I was 
 working on some 
   code to invoke HttpRuntime outside of IIS, and the HttpRuntime 
   configuration system insists on being the first caller of 
   System.Configuration. At the time, I understood the 
 log4net assembly 
   attribute as responsible for loading the configuration 
 system, and 
   thought, how hard could this be to do in code.
   The
   answer was not hard, and I got the side benefits of not having to 
   maintain dozens of log4net config files scattered in the 
 flotsam and 
   jetsam of 4 years of development. And, it would not 
 require any fuss 
   when versions change, unlike the publicpolicytoken 
 attribute of the 
   xml configuration file. And, I can use injection 
 techniques to add 
   logging setup to my apps with minmal coding.
   Dang!
   
   Then nhibernate entered the picture and decided to log on 
 it's own, 
   bad behavior for a library except for debug logging IMHO.
   
   --- Philip Nelson [EMAIL PROTECTED] wrote:
   
I had added a configuration that built my loggers in 
 code only and 
all
   was
well
(no xml!). Later though, I found out that NHibernate is doing 
something
   bad,
logging exceptions with log.Error. These exceptions are 
 handled by 
the caller, so I really don't want those log calls made 
 at all. No 
problem, I thought
   I'd
create a 

RE: Trouble with PropertyFilter

2005-12-13 Thread Nicko Cadell
The filters are a chain. Each filter in the chain has three options:
Accept, Deny, Neutral. The Accept and Deny option are effective
immediate and the other filters are ignored. If the filter selects the
Neutral option then the logging event is passed to the next filter in
the chain. When the logging event reaches the end of the chain it is
implicitly accepted.

The PropertyFilter will Accept if the property value matches the string
specified, otherwise it will allow the event to fall through to the next
filter. Therefore you need a deny all filter at the end of the chain to
ignore all other events.

This design allows the filter chain to be set up very flexibly, it can
be used to allow several different conditions or it can be reversed to
deny only those same conditions.

Cheers,
Nicko


 -Original Message-
 From: Billy Barnum [mailto:[EMAIL PROTECTED] 
 Sent: 29 November 2005 23:38
 To: 'Log4NET User'
 Subject: RE: Trouble with PropertyFilter
 
 As always, very helpful, Ron. Thanks, that worked.
 
 Just so I'm clear, though ...
 
 If these filters are additive, then why do I get everything 
 if I don't specify any filter at all? And if they're 
 subtractive, why do I need the DenyAllFilter at all? Or is 
 there something special about DenyAllFilter?
 
 See what I mean? How do these filters work together? Is there 
 a documentation section that outlines it so you don't hafta 
 'splain? I didn't see one.
 
 -BillyB
 
 
 WILLIAM BARNUM
 [EMAIL PROTECTED]
  
 
 -Original Message-
 From: Ron Grabowski [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 29, 2005 3:13 PM
 To: Log4NET User
 Subject: Re: Trouble with PropertyFilter
 
  filter type=log4net.Filter.PropertyFilter
   Key value=LogEventCategory /
   StringToMatch value=AssertionHandling /  /filter  
 filter type=log4net.Filter.DenyAllFilter /
 
 --- Billy Barnum [EMAIL PROTECTED] wrote:
 
  I'm having trouble making a PropertyFilter work with some custom 
  properties of mine, and the archives didn't turn up anything. I'm 
  probably not understanding what PropertyFiltering is or am 
  fat-fingering something; help appreciated.
  
  Expected Behavior: a certain FileAppender named 'AssertionException'
  will
  only contain Events with a custom property 
 'LogEventCategory' set to a 
  value of 'AssertionHandling'.
  Actual Behavior: no filtering takes place; all events 
 logged to this 
  appender's output file.
  
  The appender definition is:
  
  appender name=AssertionException
  type=log4net.Appender.FileAppender
  filter type=log4net.Filter.PropertyFilter
  Key value=LogEventCategory /
  StringToMatch value=AssertionHandling /
  /filter
  file value=..\..\AssertionException.txt /
  appendToFile value=false /
  layout type=log4net.Layout.PatternLayout
  conversionPattern value=[%date] [%thread] [%-5level] 
  [%property{LogEventContext}] [%property{LogEventCategory}] 
 [%logger] 
  [%ndc] [%property{LogEventType}] [%property{LogEventId}] 
  [%property{LogEventUserId}] [%message]%newline /
  /layout
  /appender
  
  Internal debugging output shows nothing untoward that I can see; I 
  found the
  following:
  
  log4net: XmlHierarchyConfigurator: Loading Appender 
  [AssertionException]
  type: [log4net.Appender.FileAppender]
  log4net: XmlHierarchyConfigurator: Setting Property [Key] to String 
  value [LogEventCategory]
  log4net: XmlHierarchyConfigurator: Setting Property 
 [StringToMatch] to 
  String value [AssertionHandling]
  log4net: XmlHierarchyConfigurator: Setting Collection Property 
  [AddFilter] to object [log4net.Filter.PropertyFilter]
  
  Here's subset of log output showing property 'LogEventCategory'
  values of
  'ExecutionTrace' (not desired) and 'AssertionHandling':
  
  [2005-11-29 12:18:23,159] [8164] [DEBUG] [BMTSecurity] 
  [ExecutionTrace] [BMT.Shared.Security.Guard.SecurityGuard] [(null)] 
  [EndMethod] [Authenticate] [BMT\bbarnum] [End Authenticate()]
  [2005-11-29 12:18:23,159] [8164] [FATAL] [NUnit] 
 [AssertionHandling] 
  [BMT.Shared.Security.Test.tSecurityGuard] [(null)] 
  [AssertionException] [Authenticate_0002] [BMT\bbarnum] [= 
  Exception # 0=
  ExceptionType: AssertionException
  Message: 
  Source: nunit.framework
  StackTrace:at NUnit.Framework.Assert.Fail(String message,
  Object[] args)
 at NUnit.Framework.Assert.IsTrue(Boolean condition)
 at 
 BMT.Shared.Security.Test.tSecurityGuard.Authenticate_0002() in 
  c:\data\code\visual studio
 
 projects\bmt\shared\vertical\bmt.shared.vl.security\test\class
 \tsecurityguar
  d.cs:line 123
  TargetSite: Void Fail(System.String, System.Object[]) ]
  
  So what am I not getting, here?
  
  -BillyB
  
  WILLIAM BARNUM
  [EMAIL PROTECTED]
   
  
  
 
 


RE: log4net and Microsoft Transactions

2005-12-13 Thread Nicko Cadell
You can disable auto-enlistment in existing transactions by specifying
Enlist=false as a connection string parameter for a SqlConnection, e.g.

Data Source=localhost;Integrated Security=SSPI;Initial
Catalog=Northwind;Enlist=false

From:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconenlistingindis
tributedtransaction.asp 



 -Original Message-
 From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
 Sent: 07 December 2005 22:21
 To: Log4NET User
 Subject: RE: log4net and Microsoft Transactions
 
 A 587k .bmp attachment?! Yikes that's big. If it were a .png 
 it probably be less than 10k. Anyway, you may find this thread useful:
 
 http://tinyurl.com/ceu7m
 http://www.mail-archive.com/log4net-user%40logging.apache.org/
 msg02238.html
 
 It looks like Michael Collier had a similiar issue and was 
 able to solve it by making FastDbAppender:
 
 http://tinyurl.com/9f6wn
 http://svn.apache.org/viewcvs.cgi/logging/log4net/trunk/exampl
 es/net/1.0/Appenders/SampleAppendersApp/cs/src/Appender/FastDb
 Appender.cs?view=markup
 
 extend ServicedComponent and marking the class with the 
 [Transaction(TransactionOption.NotSupported)] attribute.
 
 - Ron
 
 --- Ramaa Davanagere [EMAIL PROTECTED] wrote:
 
   
  
  We are using MTS transactions. I will try my best to elaborate the 
  problem.
  
   
  
  Please open the bmp file before reading.  This bmp file 
 shows how the 
  process flows in our product.
  
   
  
  The user will login via the login page and goes to the Main 
 ASP Page.
  
  
   
  
  Components A, B, C and D are VB COM components and are 
 listed in COM+ 
  applications.  The transaction for Component A is set to Required
  and the
  transactions for B, C and D are set to supported
  
   
  
  Component E is the common tracing COM component that acts 
 as a bridge 
  between vb com components (B,C, D) and the c# error handler 
 (component 
  F) that uses log4net.
  
   
  
  Component F is c#.net component which uses log4net and 
 writes messages 
  to the log file (messages.txt). I have generated a type library of 
  this component so that it can be used as a interop in Component E.
  
   
  
  All is working well (actually Prefect) when the transaction 
 is changed 
  to supported for component A. But if it's set to 
 Required, I see 
  the following errors in the log file.
  
   
  
  2147168246: New transaction cannot enlist in the specified 
 transaction 
  coordinator.
  
   
  
  Please let me know if you need more details
  
   
  
  I desperately need help.
  
   
  
   
  
  -Original Message-
  From: Georg Jansen [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, December 07, 2005 10:31 AM
  To: 'Log4NET User'
  Subject: RE: log4net and Microsoft Transactions
  
   
  
  Ramma,
  
   
  
  What kind of transaction, database transactions or mts 
 transactions or 
  .?
  
  Could you pls. elaborate?
  
   
  
  Best regards
  
  Georg
  
  http://www.l4ndash.com http://www.l4ndash.com/  - Log4Net 
 Dashboard 
  / Log Viewer
  
   
  
   
  
   
  
_
  
  From: Ramaa Davanagere [mailto:[EMAIL PROTECTED]
  Sent: 7. desember 2005 15:39
  To: 'Log4NET User'
  Subject: log4net and Microsoft Transactions
  
   
  
  Has anybody had any problem in log4net with Microsoft transactions?
  
   
  
  
 
 


RE: html output

2005-12-13 Thread Nicko Cadell
You can leverage the existing (Rolling)FileAppender infrastructure by
writing a Layout object that renders HTML. There is an example appender
in the log4net source code log4net.Layout.SimpleLayout (in the download
incubating-log4net-1.2.9-beta\src\Layout\SimpleLayout.cs). It should be
simple to extend this to output HTML formatted text. You don't need to
modify log4net you can reference your custom layout in your own assembly
from the log4net configuration file.

The biggest problem with logging to HTML is that HTML is not suitable to
streaming, essentially it does not support re-opening the file and
appending additional entries, this is due to the
htmlbody/body/html wrapping tags. Either you will need to use
the RollingFileAppender in RollingMode.Once where the files are never
re-opened and appended to, or if you don't care about valid HTML you
could probably just set the layout's Header text to 'htmlbody' and
then not bother closing those tags at the end of the file. (depends on
how strict your browser is).

Cheers,
Nicko

 -Original Message-
 From: Brian Gustavsen [mailto:[EMAIL PROTECTED] 
 Sent: 13 December 2005 09:07
 To: log4net-user@logging.apache.org
 Subject: html output
 
 are there any html logfile appender or is it possible to 
 write it my self ?
  
 Best Regards/Med venlig hilsen
  
 Brian Gustavsen
  
 
 
 
 Adwiza ApS
 
 Drejergangen 3 B
 
 DK-2690 Karlslunde
 
 Denmark
 
  
 
 E-mail:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 
 Web-site:www.adwiza.com 
 blocked::blocked::blocked::http://www.adwiza.com/ 
 
  
 
 Office:  +45 70 22 85 50
 
 Fax: +45 70 22 85 51
 
  
 
 Register as user at our Web-site: Click here! 
 blocked::blocked::blocked::http://www.adwiza.com/user/user_cr
 eate.asp 
 
 Sign up for our newsletter:  Click here! 
 blocked::blocked::blocked::http://www.adwiza.com/news/newslet
 ter.htm 
 
 
 
 ** The information enclosed in this electronic mail message, 
 including 
 
 ** any attachment, is the confidential property of Adwiza ApS.
 
 ** All rights reserved under copyright and applicable laws
 
  
  
 For help and support please use [EMAIL PROTECTED]
  
 


RE: Log4Net file locking

2005-12-12 Thread Nicko Cadell
Make sure that you are opening the file for Read only and that you allow
ReadWrite as the share mode, e.g.
System.IO.File.Open(filename, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);

Nicko 

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Sankalp
 Sent: 22 November 2005 09:53
 To: log4net-user@logging.apache.org
 Subject: Log4Net file locking
 
 Hi,
 We wish to port our .NET windows application logging to 
 Log4Net but are facing a problem. Our application dispays the 
 log file in a rich text box so that the user can debug 
 himself what all is happening in the application. We plan to 
 user RollingFileAppender so that logs can remain for certain 
 period pf time.
 However, there is some problem here. When we try reading the 
 log file and display it in the rich text box, then it says 
 that the file is in use and cant be accessed. Log4Net is 
 putting a lock on the file. I tried changing the locking 
 level to Minimal Lock using a file Appender but even that 
 didnt help as as soon as the log is written, we 
 simultaneoulsy display it in the rich text box.
 Pointers any one
 
 


RE: Can't log nulls with AdoNetAppender?

2005-11-18 Thread Nicko Cadell
The AdoNetAppender has been updated to support logging of null values
(mapping null to DBNull), this update has not yet made it into a release
and is only available in the source code repository. You can checkout
the latest source from the SVN repository and build your own custom
build of log4net that has the fix in, or you could just get the latest
source for the AdoNetAppender and build that into a separate assembly
and use that with your current version of log4net.

Nicko

 -Original Message-
 From: Billy Barnum [mailto:[EMAIL PROTECTED] 
 Sent: 14 November 2005 23:07
 To: 'Log4NET User'
 Subject: Can't log nulls with AdoNetAppender?
 
 My client is having me log to a SQL Server database using 
 AdoNetAppender.
 All is going smoothly except for one thing: I can't seem get 
 NULL values into database columns. Certain of the database 
 columns are of SQL Server type Int (.NET type Int32) because 
 they are primary key values in other tables and need to 
 participate in joins - but the columns allow nulls; 
 occasionally they aren't present. Whenever I pass 
 System.DBNull.Value, the logevent never makes it to the database. 
 
 My code does this:
 
 loggingEvent.Properties[BusinessId] = prmBusinessId; --- 
 1234 works here; System.DBNull.Value does not.
 
 and the corresponding parameter in my config file is this:
 
 parameter
   parameterName value=@prmBusinessId /
   dbType value=Int32 /
   size value=4 /
   layout type=log4net.Layout.PatternLayout
   conversionPattern value=%X{BusinessId} /
   /layout
 /parameter
 
 I've included internal debug output below, but I get the 
 *exact same format exception error* for successful writes to 
 the database and unsuccessful ones. SQL Server Profiler does 
 not show the statement at all when I pass in DBNulls, from 
 which I infer that log4net is choking on the null and not 
 even making the attempt.
 
 Is there no way to get nulls into these columns, or am I 
 doing something wrong?
 
 -BillyB
 
 WILLIAM BARNUM
 [EMAIL PROTECTED]
 
 log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
 log4net: XmlHierarchyConfigurator: Logger [root] Level string 
 is [DEBUG].
 log4net: XmlHierarchyConfigurator: Logger [root] level set to 
 [name=DEBUG,value=3].
 log4net: XmlHierarchyConfigurator: Loading Appender 
 [SqlServerAppender]
 type: [log4net.Appender.AdoNetAppender]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [LevelMin] to Level value [DEBUG]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [LevelMax] to Level value [FATAL]
 log4net: XmlHierarchyConfigurator: Setting Collection 
 Property [AddFilter] to object [log4net.Filter.LevelRangeFilter]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [BufferSize] to Int32 value [1]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [ConnectionType] to String value 
 [System.Data.SqlClient.SqlConnection, System.Data, 
 Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [ConnectionString] to String value [Data 
 Source=BMT2;Database=WIAN;User
 Id=wianuser;Password=wianuser;]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [Credentials] to ImpersonationMode value [Process]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [SecurityContext] to object [log4net.Util.WindowsSecurityContext]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [CommandType] to CommandType value [StoredProcedure]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [CommandText] to String value [dbo.EventLogInsStd]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [ParameterName] to String value [EMAIL PROTECTED]
 log4net: XmlHierarchyConfigurator: Setting Property [DbType] 
 to DbType value [String]
 log4net: XmlHierarchyConfigurator: Setting Property [Size] to 
 Int32 value [32]
 log4net: PatternParser: Converter [message] Option [] Format 
 [min=-1,max=2147483647,leftAlign=False]
 log4net: PatternParser: Converter [newline] Option [] Format 
 [min=-1,max=2147483647,leftAlign=False]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [ConversionPattern] to String value [%property{EventSource}]
 log4net: PatternParser: Converter [property] Option 
 [EventSource] Format [min=-1,max=2147483647,leftAlign=False]
 log4net: XmlHierarchyConfigurator: Setting Property [Layout] 
 to object [log4net.Layout.Layout2RawLayoutAdapter]
 log4net: XmlHierarchyConfigurator: Setting Collection 
 Property [AddParameter] to object 
 [log4net.Appender.AdoNetAppenderParameter]
 log4net: XmlHierarchyConfigurator: Setting Property 
 [ParameterName] to String value [EMAIL PROTECTED]
 log4net: XmlHierarchyConfigurator: Setting Property [DbType] 
 to DbType value [String]
 log4net: XmlHierarchyConfigurator: Setting Property [Size] to 
 Int32 value [32]
 log4net: PatternParser: Converter [message] Option [] Format 
 [min=-1,max=2147483647,leftAlign=False]
 log4net: PatternParser: Converter 

RE: Log4Net for Oracle 8.1.7

2005-11-13 Thread Nicko Cadell
If an error is encountered in the AdoNetAppender you will need to enable
log4net internal debuggingto see it.
http://logging.apache.org/log4net/release/faq.html#internalDebug

Nicko

 -Original Message-
 From: clady franson [mailto:[EMAIL PROTECTED] 
 Sent: 08 November 2005 07:03
 To: Log4NET User
 Subject: Re: Log4Net for Oracle 8.1.7
 
 Hi All,
 
 
 I am franson. I try to insert error into my
 oracle8.1.7 database. I cannot get any error message.
 And I cannot insert the error messeage to database.
 
 please help me to insert my message to Oracle 8i database 
 through Log4net.
 
 what are the think we need to insert my message to oracle 8i database?
 
 I am using System.Data.OracleClient in my web based application. 
 
 which oracle version is support by Log4net?
 
 I need some example.
 
 Thanks
 
 Franson.I
 
 
 
   
 __
 Enjoy this Diwali with Y! India Click here 
 http://in.promos.yahoo.com/fabmall/index.html
 
 


RE: RollingFileAppender: log files with constant extension and composite name

2005-11-13 Thread Nicko Cadell
 
 I'd like current messages to always be logged into a file 
 with the same name (e.g., mylogs.log).  

To do this you need to set the file property to the 'static' log file
name, and set the staticLogFileName property to true, e.g.:

file value=C:\\ProphIT_CTI\\mylogs.log /
staticLogFileName value=true /


 When a file hits a 
 maximum size I'd like to have the file renamed and have 
 future logs go into a new file with the same name as before 
 (i.e., mylogs.log). 

This will happen if the staticLogFileName is set to true and the
rollingStyle is Size or Composite.


 The old file would be renamed to a name 
 that includes a sequence number and date (e.g., 
 mylogs20051109.2.log for today's second log file). It would 
 be OK if the date didn't get added to the name until the next day.
 
 The RollingFileAppender does this fine except that the 
 sequence number becomes the file extension.

Currently the sequence number must be the last part of the filename,
otherwise the appender cannot identify the previously rolled files.

Nicko

 
 Is there a way to configure the RollingFileAppender to do this?
 
 I'm currently using the following configuration: 
 
 appender name=Dev4RollingFile 
 type=log4net.Appender.RollingFileAppender
   file value=C:\\ProphIT_CTI /
   maximumFileSize value=500KB /
   maxSizeRollBackups value=5 /
   datePattern value=-MM-dd'.log' /
   staticLogFileName value=false /
   rollingStyle value=Composite /
  appendToFile value=true /
   countDirection value=0 /
   layout type=log4net.Layout.XmlLayoutSchemaLog4j /
 /appender
 
 Thanks.
 --
 Mike Blake-Knox 
 


RE: log4net not logging in web services

2005-11-13 Thread Nicko Cadell
If an error is encountered you will need to enable log4net internal
debugging to see it.
http://logging.apache.org/log4net/release/faq.html#internalDebug

Nicko 

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 10 November 2005 17:32
 To: log4net-user@logging.apache.org
 Subject: log4net not logging in web services
 
 Hello,
 
 I am able to log messages on one pc (XP prof) from a .net web 
 service with out any issues to any directory (provided I give 
 permissions ASPNET user).
 But when I move the same code to another pc (XP prof), it 
 does not even create the log file (either in the 
 Inetpub\wwwroot\ or any other direcotry).
 
 I gave full control permissions to ASPNET and NETWORKSERVICES 
 accounts to the directory where the logs files should write.
 
 Any ideas? Appreciate your help.
 
 Thanks,
 Prasad Pondugula
 
 CONFIDENTIALITY NOTICE: This e-mail message, including any 
 attachments, is for the sole use of the intended recipient(s) 
 and may contain confidential and privileged information. Any 
 unauthorized review, use, disclosure of distribution is 
 prohibited.  If you are not the intended recipient, please 
 contact the sender by reply e-mail and destroy all copies of 
 the original message.
 
 
 
 
 


RE: Logging in CF on pocket pc 2003

2005-11-13 Thread Nicko Cadell
There is a log4net build for the Compact Framework. It is part of the
standard log4net download:
http://logging.apache.org/log4net/downloads.html
incubating-log4net-1.2.9-beta\bin\netcf\1.0\release

There is even a simple example in the download at:
examples\netcf\1.0\Tutorials\ConsoleApp\cs\src 

Cheers,
Nicko

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 11 November 2005 14:35
 To: log4net-user@logging.apache.org
 Subject: Logging in CF on pocket pc 2003
 
 Hello all,
 
 How do I log application / exception messages on pocket pc 
 application (developed using .net cf)? Opening a file and 
 writing to it? Or can I use log4net? Has anyone used log4net 
 or anything similar to log messages?
 
 Any other thoughts?
 
 Thanks in advance.
 
 
 
 
 


RE: TypeInitializationException was unhandled

2005-11-13 Thread Nicko Cadell
If you look at the InnerExceptions within the
TypeInitializationException you will see that the underling error is a
System.Configuration.ConfigurationErrorsException thrown by the .NET
runtime because the App.config file contains unrecognised elements.

You need to add this to your App.config file so that it is the first
element inside the config element.

configSections
  section name=log4net
type=System.Configuration.IgnoreSectionHandler /
/configSections 

Nicko

 -Original Message-
 From: Saurabh Dani [mailto:[EMAIL PROTECTED] 
 Sent: 13 November 2005 03:04
 To: Nicko Cadell
 Subject: RE: TypeInitializationException was unhandled
 
 Thanks Nicko,
 
 A sample is attached here.
 
 Saurabh
 
 
 
 
 Return-Path: 
 [EMAIL PROTECTED]
 org Sat Nov 12 18:29:59 2005
 Received: from hermes.apache.org [209.237.227.199] by 
 mail25.webcontrolcenter.com with SMTP; Sat, 12 Nov 2005 18:29:59 -0700
 Received: (qmail 67107 invoked by uid 500); 13 Nov 2005 01:29:58 -
 Received: (qmail 67096 invoked by uid 99); 13 Nov 2005 01:29:58 -
 Received: from asf.osuosl.org (HELO asf.osuosl.org) 
 (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; 
 Sat, 12 Nov 2005 17:29:58 -0800
 Received: from [80.168.17.114] (HELO hermes.neoworks.co.uk) 
 (80.168.17.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 
 12 Nov 2005 17:29:49 -0800
 Received: from kronos.neoworks.co.uk (kronos.neoworks.co.uk 
 [10.0.0.132]) by hermes.neoworks.co.uk (8.13.1/8.13.1) with 
 ESMTP id jAD1OoiT000865 for 
 log4net-user@logging.apache.org; Sun, 13 Nov 2005 01:24:54 GMT
 Mailing-List: contact [EMAIL PROTECTED]; 
 run by ezmlm
 Precedence: bulk
 list-help: mailto:[EMAIL PROTECTED]
 list-unsubscribe: mailto:[EMAIL PROTECTED]
 List-Post: mailto:log4net-user@logging.apache.org
 Reply-To: Log4NET User log4net-user@logging.apache.org
 List-Id: log4net-user.logging.apache.org
 Delivered-To: mailing list log4net-user@logging.apache.org
 X-ASF-Spam-Status: No, hits=0.8 required=10.0 tests=INFO_TLD,SPF_PASS
 X-Spam-Check-By: apache.org
 Received-SPF: pass (asf.osuosl.org: domain of 
 [EMAIL PROTECTED] designates 80.168.17.114 as permitted sender)
 Content-class: urn:content-classes:message
 Subject: RE: TypeInitializationException was unhandled
 MIME-Version: 1.0
 Content-Type: text/plain;
 charset=us-ascii
 Content-Transfer-Encoding: quoted-printable
 x-mimeole: Produced By Microsoft Exchange V6.5.6944.0
 Date: Sun, 13 Nov 2005 01:29:28 -
 Message-ID: 
 [EMAIL PROTECTED]
 X-MS-Has-Attach: 
 X-MS-TNEF-Correlator: 
 Thread-Topic: TypeInitializationException was unhandled
 Thread-Index: AcXjlWjJng8sg0d8Qgq4PqpSyLu0+AEW9J4w
 From: Nicko Cadell [EMAIL PROTECTED]
 To: Log4NET User log4net-user@logging.apache.org
 X-Virus-Checked: Checked by ClamAV on apache.org
 X-SmarterMail-Spam: SPF_Pass
 X-Rcpt-To: [EMAIL PROTECTED]
 
 Can you send me a complete (simple) project that reproduces 
 this. I have tried to reproduce this issue with the RTM build 
 of .NET 2.0 in a Windows App and in an ASP.NET App. I have 
 tried using the 1.2.9 log4net assembly build against .NET 1.0 
 and with a version built against .NET 2.0. So far I have not 
 been able to reproduce the TypeInitializationException.
 
 Thanks,
 Nicko
 
  -Original Message-
  From: Saurabh Dani [mailto:[EMAIL PROTECTED]
  Sent: 05 November 2005 10:00
  To: log4net-user@logging.apache.org
  Subject: RE: TypeInitializationException was unhandled
  
  Is anyone else able to use log4net with ASP.net 2.0? I am 
 getting same 
  exception with this sample program.
  
  Saurabh
  
  
  
  
  Return-Path: 
  
  org Mon Oct 10 21:39:31 2005
  Received: from hermes.apache.org [209.237.227.199] by 
  mail25.webcontrolcenter.com with SMTP; Mon, 10 Oct 2005 
 21:39:31 -0700
  Received: (qmail 23025 invoked by uid 500); 11 Oct 2005 
 04:39:29 -
  Received: (qmail 23014 invoked by uid 99); 11 Oct 2005 
 04:39:29 -
  Received: from asf.osuosl.org (HELO asf.osuosl.org)
  (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; 
 Mon, 10 Oct 
  2005 21:39:29 -0700
  Received: from [66.163.178.50] (HELO
  web33803.mail.mud.yahoo.com) (66.163.178.50) by apache.org
  (qpsmtpd/0.29) with SMTP; Mon, 10 Oct 2005 21:39:30 -0700
  Received: (qmail 17888 invoked by uid 60001); 11 Oct 2005
  04:39:06 -
  Received: from [59.161.71.20] by 
 web33803.mail.mud.yahoo.com via HTTP; 
  Mon, 10 Oct 2005 21:39:06 PDT
  Mailing-List: contact [EMAIL PROTECTED];
  run by ezmlm
  Precedence: bulk
  list-help: 
  list-unsubscribe: 
  List-Post: 
  Reply-To: Log4NET User 
  List-Id: 
  Delivered-To: mailing list log4net-user@logging.apache.org
  X-ASF-Spam-Status: No, hits=1.3 required=10.0 
  tests=DNS_FROM_RFC_ABUSE,INFO_TLD
  X-Spam-Check-By: apache.org
  Received-SPF: pass (asf.osuosl.org: local policy)
  DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; 
 d=yahoo.com; 
  h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Ve

RE: TypeInitializationException was unhandled

2005-11-12 Thread Nicko Cadell
Can you send me a complete (simple) project that reproduces this. I have
tried to reproduce this issue with the RTM build of .NET 2.0 in a
Windows App and in an ASP.NET App. I have tried using the 1.2.9 log4net
assembly build against .NET 1.0 and with a version built against .NET
2.0. So far I have not been able to reproduce the
TypeInitializationException.

Thanks,
Nicko

 -Original Message-
 From: Saurabh Dani [mailto:[EMAIL PROTECTED] 
 Sent: 05 November 2005 10:00
 To: log4net-user@logging.apache.org
 Subject: RE: TypeInitializationException was unhandled
 
 Is anyone else able to use log4net with ASP.net 2.0? I am 
 getting same exception with this sample program.
 
 Saurabh
 
 
 
 
 Return-Path: 
 [EMAIL PROTECTED]
 org Mon Oct 10 21:39:31 2005
 Received: from hermes.apache.org [209.237.227.199] by 
 mail25.webcontrolcenter.com with SMTP; Mon, 10 Oct 2005 21:39:31 -0700
 Received: (qmail 23025 invoked by uid 500); 11 Oct 2005 04:39:29 -
 Received: (qmail 23014 invoked by uid 99); 11 Oct 2005 04:39:29 -
 Received: from asf.osuosl.org (HELO asf.osuosl.org) 
 (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; 
 Mon, 10 Oct 2005 21:39:29 -0700
 Received: from [66.163.178.50] (HELO 
 web33803.mail.mud.yahoo.com) (66.163.178.50) by apache.org 
 (qpsmtpd/0.29) with SMTP; Mon, 10 Oct 2005 21:39:30 -0700
 Received: (qmail 17888 invoked by uid 60001); 11 Oct 2005 
 04:39:06 -
 Received: from [59.161.71.20] by web33803.mail.mud.yahoo.com 
 via HTTP; Mon, 10 Oct 2005 21:39:06 PDT
 Mailing-List: contact [EMAIL PROTECTED]; 
 run by ezmlm
 Precedence: bulk
 list-help: mailto:[EMAIL PROTECTED]
 list-unsubscribe: mailto:[EMAIL PROTECTED]
 List-Post: mailto:log4net-user@logging.apache.org
 Reply-To: Log4NET User log4net-user@logging.apache.org
 List-Id: log4net-user.logging.apache.org
 Delivered-To: mailing list log4net-user@logging.apache.org
 X-ASF-Spam-Status: No, hits=1.3 required=10.0 
 tests=DNS_FROM_RFC_ABUSE,INFO_TLD
 X-Spam-Check-By: apache.org
 Received-SPF: pass (asf.osuosl.org: local policy)
 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; 
 d=yahoo.com; 
 h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Ve
 rsion:Content-Type:Content-Transfer-Encoding;
 b=wvcgcYfX1IUaaxPO2cAIFVTj6Bk3ZlUhKdjfT0ahHmmFwOC4rYjHdR1JZH0+
BBNcVPWTo7i4358I+/h+X6FKoiYN/TyS/zy+q0eiSMmwOsCOuq9miQJ2r387fjCMZ6OmQP+H
T89zoEibx8Si1xfkLHTrmmVcIO0q9hA4lmqRYO8= ;
 Message-ID: [EMAIL PROTECTED]
 Date: Mon, 10 Oct 2005 21:39:06 -0700 (PDT)
 From: depsi programmer [EMAIL PROTECTED]
 Subject: RE: TypeInitializationException was unhandled
 To: Log4NET User log4net-user@logging.apache.org
 In-Reply-To: 
 [EMAIL PROTECTED]
 MIME-Version: 1.0
 Content-Type: text/plain; charset=iso-8859-1
 Content-Transfer-Encoding: 8bit
 X-Virus-Checked: Checked by ClamAV on apache.org
 X-SmarterMail-Spam: SPF_Pass
 X-Rcpt-To: [EMAIL PROTECTED]
 
 Thanks 
 
 I am building a Windows Application using Microsoft Visual 
 Basic 2005 Beta 2.
 
 In my app.config file I have put
 
 type=log4net.Appender.RollingFileAppender
 
 
 
 
 
 type=log4net.Appender.RollingFileAppender+MinimalLock/
 
 
 value=%date|[%thread]|%-5level|%logger|%property{NDC}|%messag
 e%newline/
 
 
 
 
 
 
 
 
 
 
 The sample application code in which I am trying to write log 
 for a button click with time of clicking is:
 
 Public Class Form1
 'Declaration part
 Private Shared ReadOnly logger As log4net.ILog =
 log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetC
 urrentMethod().DeclaringType)
 
 Private Sub Form1_Load(ByVal sender As Object, ByVal e As 
 System.EventArgs) Handles Me.Load
 log4net.Config.XmlConfigurator.Configure()
 'Initialize log4net --- here it generates exception End Sub
 
 Private Sub Button1_Click(ByVal sender As System.Object, 
 ByVal e As System.EventArgs) Handles Button1.Click 'trying to 
 write in log
 log4net.NDC.Push(Form1.vb)
 logger.Info(Button1 Clicked at :  Now)
 log4net.NDC.Pop()
 End Sub
 End Class
 
 
 --- Nicko Cadell wrote:
 
  What type of application are you building? From the look of 
 the call 
  stack it looks like some kind of VS add-in. If so which 
 version of VS?
  I can't reproduce this with a simple forms app so it may be some 
  interaction with the hosting process.
  
  Is it possible for you to post the source to a bare bones 
 version of 
  your app? Just something that it launched in the same way, 
 has a form 
  which is displayed, and calls XmlConfigurator.Configure from the 
  OnLoad method. If I can reproduce the problem it is much easier to 
  fix.
  
  Cheers,
  Nicko
  
   -Original Message-
   From: depsi programmer
  [mailto:[EMAIL PROTECTED]
   Sent: 04 October 2005 05:40
   To: Log4NET User
   Subject: TypeInitializationException was unhandled
   
   Hi
   
   I am getting following error in log4.net
   
   The exact error message and stack trace:
   
   System.TypeInitializationException was unhandled
   
   Message=The type initializer

RE: What do I need to do to get rid of this error? Please help

2005-11-06 Thread Nicko Cadell
By default the log4net FileAppender takes an exclusive write lock on the
log file. If you have multiple processes that are logging to the same
file then you need to use a different locking model. For example the
MinimalLock model:

lockingModel type=log4net.Appender.FileAppender+MinimalLock /

This locking model takes a write lock on the file as each logging event
written and then releases it immediately.

An example configuration is:

appender name=FileAppender type=log4net.Appender.FileAppender
  lockingModel type=log4net.Appender.FileAppender+MinimalLock /
  file value=c:\tmp\test-file.txt /
  layout type=log4net.Layout.PatternLayout value=%d [%t] %-5p %c -
%m%n /
/appender 

Cheers,
Nicko

 -Original Message-
 From: Ramaa Davanagere [mailto:[EMAIL PROTECTED] 
 Sent: 04 November 2005 17:12
 To: 'Log4NET User'
 Subject: RE: What do I need to do to get rid of this error? 
 Please help
 
  
 
 I wish it was that easy
 
  
 
 I have multiple components (20+) using the same log file for 
 logging messages.  I don't think I can check which of the 
 components is currently locking the files, before writing log 
 messages.
 
  
 
 How do I resolve this?
 
  
 
 -Original Message-
 From: Shireesh Thanneru [mailto:[EMAIL PROTECTED]
 Sent: Friday, November 04, 2005 11:55 AM
 To: Log4NET User
 Subject: Re: What do I need to do to get rid of this error? 
 Please help
 
  
 
 You need to make sure that no other process/program is 
 accessing the the file at C:\Program 
 Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt
 
 so that log4net can acquire a lock on that file.
 
 Ramaa Davanagere [EMAIL PROTECTED] wrote:
 

 

 
   log4net: RollingFileAppender: Searched for existing 
 files in [C:\Program Files\Mobius\contenuity\LogFiles]
 
   log4net: RollingFileAppender: curSizeRollBackups starts at [0]
 
   log4net: FileAppender: Opening file for writing 
 [C:\Program Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt] 
 append [True]
 
   log4net:ERROR [RollingFileAppender] Unable to acquire 
 lock on file C:\Program 
 Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt. The process 
 cannot access the file C:\Program 
 Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt because it 
 is being used by another process.
 
   log4net:ERROR [RollingFileAppender] OpenFile(C:\Program 
 Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt,True) call failed.
 
   LockStateException: The file is not currently locked
 
  at log4net.Appender.LockingStream.AssertLocked()
 
  at log4net.Appender.LockingStream.get_CanWrite()
 
  at System.IO.StreamWriter..ctor(Stream stream, 
 Encoding encoding, Int32 bufferSize)
 
  at System.IO.StreamWriter..ctor(Stream stream, 
 Encoding encoding)
 
  at log4net.Appender.FileAppender.OpenFile(String 
 fileName, Boolean append)
 
  at 
 log4net.Appender.RollingFileAppender.OpenFile(String 
 fileName, Boolean append)
 
  at log4net.Appender.FileAppender.SafeOpenFile(String 
 fileName, Boolean append)
 
   log4net: FileAppender: Opening file for writing 
 [C:\Program Files\Mobius\contenuity\LogFiles\vdrconBOLog.txt] 
 append [True] 
 
 


RE: newbie - log4net deletes my config file!

2005-11-01 Thread Nicko Cadell
Actually Visual Studio is deleting your config file.

Create a file called App.config in the root of your VisualStudio
project.
Visual Studio will automagically copy this file into the build output
directory and rename it to log4netConsoleTest.exe.config.
Put your log4net configuration in the App.config file.

As for not finding the file; When you call XmlConfigurator.Configure()
then log4net calls
System.Configuration.ConfigurationSettings.GetConfig(log4net). If this
returns null then it prints out the message you are seeing. It does not
know where the file is or try to guess, it just asks the .NET
configuration API for its configuration. There are other ways of calling
XmlConfigurator.Configure(), for example passing a FileInfo param, which
will cause log4net to look for a specific file, then it will print out a
file not found message.

Cheers,
Nicko


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 01 November 2005 20:48
 To: log4net-user@logging.apache.org
 Subject: newbie - log4net deletes my config file!
 
 
 I'm a .net and log4net newbie working thru the tutorial at 
 http://www.codeproject.com/csharp/log4net_intro.asp 
 
 First example, logging to console with no config file, works 
 fine. 2nd example, using a small config file, I see two problems. 
 The main problem is that my config file is deleted from the 
 system when I run the project.  Here is the complete code of 
 the project: 
 using System;
 using log4net; 
 
 namespace log4netConsoleTest
 { 
 public class MainTestClass 
 { 
 private static  ILog logger = 
 LogManager.GetLogger(typeof (MainTestClass)); 
 
 // constructor: 
 static MainTestClass () 
 { 
 log4net.Config.XmlConfigurator.Configure(); 
 } 
 
 static void Main(string[] args) 
 { 
 logger.Debug(Here is a debug log.); 
 logger.Error(... and a non-fatal error.); 
 logger.Fatal(... and a fatal error.); 
 } 
 }
 } 
   
 When I look into the file directory where the exe file lives, 
 I see that file log4netConsoleTest.exe.config' exists. When 
 I run the project and stop at the 'LogManager.GetLogger' 
 line, and then look again into the file directory, the config 
 file is gone!   If I restore the file into the directory at 
 that time, then the logging works as expected. 
 
 if I don't restore the file, log4net write this to the console: 
 log4net:ERROR XmlConfigurator: Failed to find configuration 
 section 'log4net' in the application's .config file. Check 
 your .config file for the log4net and configSections 
 elements. The configuration section should look like: 
 section name=log4net 
 type=log4net.Config.Log4NetConfigurationSectionHandler,log4net / 
 I think that is also a problem. It apparently can't find the 
 file (cause it doesn't exist), but instead of saying 'file 
 not found', it says it can't find certain chars inside the 
 file.  I'd like the error message to include the fully 
 qualified name of where it looked for the file. 
 
 All help appreciated,
 Erik Brooks
 
 
 ---
 IMPORTANT NOTIFICATION
 ---
 The contents of this e-mail and its attachments are 
 confidential and may be privileged. If you are not the 
 intended recipient of this e-mail, please notify IDX 
 immediately (by return e-mail to either the sender or 
 [EMAIL PROTECTED]), destroy all copies of this message along 
 with any attachments and do not disclose, copy and/or 
 distribute the contents. The views expressed in this message 
 are those of the author and not necessarily those of IDX. In 
 the absence of a prior written agreement with you authorizing 
 commitments of IDX via e-mail, the above message shall not 
 bind IDX, unless from a duly authorized officer of the 
 company in a context indicating an intention to bind the company. 
 
 This e-mail and its attachments are protected by copyright 
 and other laws. (c) IDX Systems Corporation 2005. All rights 
 reserved. IDX is a registered trademark of IDX Investment Corporation.
 
 


RE: HostName property sometimes empty

2005-10-30 Thread Nicko Cadell
Simon,

The hostname should always be set. Are you seeing this behaviour
reliably and repeatably? What is the difference between the scenarios
where it works and where it does not?
Have you tried reproducing this with 1.2.9?

Nicko 

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 24 October 2005 23:57
 To: Log4NET User
 Subject: HostName property sometimes empty
 
 Hi,
 
 I'm having a problem where I'm trying to log the HostName 
 property (like this: %P{log4net:HostName}) and on some 
 servers it seems to work and on others it doesn't. I'm using 
 v1.2.8 and trying to log to both text files and SQL Server. 
 In both scenarios I have some cases where it works and some 
 where it doesn't.
 
 Has anyone else had this problem of the HostName property 
 being empty??
 
 Thanks,
 Simon.
 
 


RE: DebugView doesn't capture when using Remote Desktop

2005-10-30 Thread Nicko Cadell
Simon,

I'm not really sure what would cause this behaviour. It might be a
question for the sysinternals folks.

Nicko 

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 25 October 2005 00:01
 To: Log4NET User
 Subject: DebugView doesn't capture when using Remote Desktop
 
 Hi,
 
 I can use DebugView locally and it always works. However when 
 I use Remote Desktop to some of our servers and try to run 
 it, it doesn't seem to capture anything. I'm running it 
 locally on the server I'm remoting into, but no luck. I do 
 have debugging turned on in both the web.config and 
 log4net.config files.
 
 Has anyone used DebugView successfully on a remote server 
 with log4net?
 
 Thanks,
 Simon.
 
 


RE: Log4Net Reports

2005-10-30 Thread Nicko Cadell
Personally I like to give the application/system administrator control
over the log4net configuration. It's up to them to decide where they
want the application logging information to go. One of the main features
of log4net is that the location of the log output can be changed after
the application has been deployed.

My applications do not depend on log4net for their functionality, if I
disable logging my applications still continue to function. 

If I have a functional requirement to record specific reporting
information I would probably not use log4net to output it, but would
write it directly to a database. It is possible to configure log4net to
do some of the work for you, but it is designed to support application
logging rather than reporting.

Cheers,
Nicko

 -Original Message-
 From: Dawson Mossman [mailto:[EMAIL PROTECTED] 
 Sent: 23 October 2005 20:43
 To: log4net-user@logging.apache.org
 Subject: Log4Net Reports
 
 Hi,
 I know the primary purpose of Log4Net is logging capability 
 in your application.  However, I'm wondering if it's also 
 used/recommended for Reporting?
 
 I've heard talk of people using Log4Net to generate logging 
 information that they intend to use for creating reports.  Is 
 this a recommended strategy?  
 Or should application reporting be kept separate from Log4Net entries?
 
 From what I understand, it's common for Log4Net to be turned 
 off in a production application and only turned on when 
 required to debug a problem.  
 If this is the typical usage, then clearly reporting based on 
 Log4Net would not be recommended.
 
 If you could clear this for me, it would avoid steering 
 several projects in the wrong direction.
 
 Thanks.
 
 
 
 


RE: log files get reset at 12:00 noon every day

2005-10-30 Thread Nicko Cadell
Simon,

There have been a number of fixes to the File  RollingFile appenders
since 1.2.8. If you cannot upgrade the latest version you may want to
consider taking the latest source for 2 appenders, back porting them
where necessary, and building them into a new dll. You could then uses
these appenders with the old 1.2.8 build of log4net, just specify the
assembly qualified type name in the logging configuration.

Cheers,
Nicko

 -Original Message-
 From: Simon Wallis [mailto:[EMAIL PROTECTED] 
 Sent: 28 October 2005 19:27
 To: Log4NET User
 Subject: Re: log files get reset at 12:00 noon every day
 
 I'm using 1.2.8. Unfortunately I cannot upgrade to 1.2.9 
 because I have written a set of log4net extensions and there 
 are a lot of small breaking changes in 1.2.9.
 
 I've been using 1.2.8 for almost a year and have not seen 
 this happen until now when I deployed my code to a set of new 
 servers. I'll search the archives for your postings, but 
 unfortunately upgrading is not an option right now.
 
 Thanks,
 Simon.
 
 -Original message-
 From: Baron Schwartz [EMAIL PROTECTED]
 Date: Fri, 28 Oct 2005 08:00:49 -0700
 To: Log4NET User log4net-user@logging.apache.org
 Subject: Re: log files get reset at 12:00 noon every day
 
  I had this problem as well a while ago.  Upgrading solved 
 it.  Search 
  the mail archives for my message for specifics.  Be sure 
 you are using 
  the latest versions from the log4net site, not the 
 sourceforge site -- 
  it is stale there.
  
  Simon Wallis wrote:
   Yes, datePattern specifies when it should roll over. The 
 pattern I used specifies a daily roll over. The log files do 
 roll over correctly at midnight. So at midnight last night, a 
 new log file was created named WS.error.20051028.log (the 
 quot;logquot; appends log to the filename).
   
   But then, why does it roll over again at noon? The log 
 file will be full of entries until 11:59:59, and then the 
 next second the file is empty and starts to record again at 12:00:00.
   
   Again, this works on my local machine, but on the servers 
 Ive deployed it to it does the above strange behaviour.
   
   Does anyone have any clues???
   
   Simon.
   
   -Original message-
   From: Matthew Brown [EMAIL PROTECTED]
   Date: Fri, 28 Oct 2005 05:34:25 -0700
   To: Log4NET User log4net-user@logging.apache.org
   Subject: Re: log files get reset at 12:00 noon every day
   
   
  datePattern value=.MMdd.quot;logquot; /
  
  Isn't datePattern the parameter to specify when the 
 rollover should 
  occur? If it is, you have it set to daily. Not sure why it would 
  choose 12pm rather than 12am but I am curious what effect the 
  quot;logquot; string would have on that...
  
  On 10/27/05, Simon Wallis [EMAIL PROTECTED] wrote:
  
  Hi,
  
  This is totally weird. Every day at 12:00 noon the log 
 files from our app lication get reset. If I check them in 
 the morning, there are entries start ing in the night, 
 there's entries throughout the morning, and then exactly  at 
 noon log4net seems to delete the file and recreate it, so all 
 the entrie s from midnight until noon are deleted.
  
  This is only happening in our recently deployed QA and 
 production environ ments. It works fine locally. I'm also 
 logging to a database and that is fi ne. I made sure that 
 the Regional date settings (in control panel) are the  same, 
 I just have no idea why this is happening. It is quite bizarre.
  
  Here is the snipped from my log4net config file:
  
  !-- ERROR LOG - text file that rolls on a daily 
 basis --
  appender name=ErrorRollingFileAppender 
 type=log4net.Appen der.RollingFileAppender
  filter type=log4net.Filter.LevelRangeFilter
  levelMin value=WARN /
  levelMax value=FATAL /
  /filter
  rollingStyle value=Date /
  datePattern value=.MMdd.quot;logquot; /
  file 
 value=D:\\myfolder\\Logging\\hidc2\\WS.error /
  appendToFile value=true /
  param name=StaticLogFileName value=false /
  layout type=log4net.Layout.PatternLayout
  conversionPattern value=%d 
 %-7p %c  quot;%m quot; %P{SessionId} %P{ProfileId} 
 %P{XmlData} %n /
  /layout
  /appender
  
  Is anything wrong with it?
  
  Thanks for your help,
  Simon.
  
   
   
   
 
 


RE: Custom global param

2005-10-22 Thread Nicko Cadell
Currently it is not possible to set arbitrary properties from the
log4net config file. You will need to load this flag yourself probably
from the your application's .config file.

I will raise this as an issue on the dev list. So we may make some
progress on this.

Cheers,
Nicko

 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Blake Bishop
 Sent: 18 October 2005 23:41
 To: log4net-user@logging.apache.org
 Subject: Custom global param
 
 Hi all,
 
 Does the log4net framework support custom parameters that I 
 can retrieve in code?  Basically, I would like to set a 
 property called VERBOSITY in the log4net config file that I 
 could retrieve in code and use to manipulate my messages that 
 get sent to the logger.  When this value is ON I would 
 append stack trace info to messages, regardless of the log 
 level I will log the message at.  I've seen a couple of 
 threads about people adding log levels by rolling their own 
 extensions, but I'd like to know if there is another way.  
 Here is a basic example of what I'm trying to accomplish:
 
 log4net
   !-- Custom parameter that can be read by my application --
   param name=VERBOSITY value=ON /
 
   root.../root
   logger.../logger
   ...
 /log4net
 
 -
 
 class MyClass {
   internal static log4net.ILog log =
 log4net.LogManager.GetLogger(TestLogging);
   internal static bool isDebug = log.IsDebugEnabled;
   internal static bool isVerbose = ??? //
 
   public void MyMethod(){
 
 // some code in some method that throws an exception
 try { //some code to try }
 catch (MyException ex) {
   string messageString = ex.Message;
   if(isVerbose) {
 // code that extracts the stack trace
   }
 
   // I could use log.Warn() or log.Info() or whatever -- 
 verbose-independent
   log.Error(messageString);
 }
   }
 }
 
 Thanks in advance,
 Blake 
 
 
 
 
 


RE: Log4net seems to hang when starting up windows service

2005-10-22 Thread Nicko Cadell
Gary, I haven't heard anything about potential hangs in
Process.GetCurrentProcess() do you have any references for this?

John, Can you test this by removing the %r pattern from your appenders?

Cheers,
Nicko

 -Original Message-
 From: Gary Overholt [mailto:[EMAIL PROTECTED] 
 Sent: 22 October 2005 01:40
 To: log4net-user@logging.apache.org
 Subject: RE: Log4net seems to hang when starting up windows service
 
 John,
 
 
 I hit this same problem a couple of weeks ago after I 
 converted from the 1.2.b8 version to the current verion of 
 log4net. After looking at this list and not finding anyone 
 else having this problem (until now) I looked at the log4net code.
 
 After doing a bit of debugging I found the program hangs 
 because of the use of the %r in the conversion pattern and 
 tracked it to this line in the file
 Util/SystemInfo.Cs:
 
 
  s_processStartTime = 
 System.Diagnostics.Process.GetCurrentProcess().StartTime;
  
 After looking on the web, I found references indicating that 
 the System.Diagnostics.Process.GetCurrentProcess property 
 sometime stalls in certain conditions.
 
 So what I did was replace this line in Util/SystemInfo.Cs :
 
   private static DateTime s_processStartTime = DateTime.MinValue;
 
   with:
 
   private static DateTime s_processStartTime = DateTime.Now;
 
 
 This effectivly changes the %r conversion pattern to report 
 ticks since the
 SystemInfo Class was loaded rather than the actual start of 
 the program.   So
 beware of this.
 
 As a side effect I no longer get negative ticks like I 
 sometimes used to. This happened when the code did not hang 
 but threw an exception in trying to get the process start 
 time and set the s_ProcessStartTime to DateTime.Now - which 
 was after the time of the event that was being logged.
 
 This is just a patch to allow me to run log4net in a Windows 
 services ( I also suspect ASP.Net Apps and Web Services but 
 have no evidence to support it) and there may be another 
 cause - but it worked for me.  Perhaps the log4net guru's 
 have some insight on this.
 
 - gary
 
 
 
 Gary Overholt 
 
 (303)359-9924
 [EMAIL PROTECTED]
 
 
   
   
 __
 Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
 
 


RE: DefaultDomain / Repository Question

2005-10-10 Thread Nicko Cadell
Using the default domain is now the default behaviour. To get the
behaviour you want you should not specify a DomainAttribute at all.

Cheers,
Nicko

 -Original Message-
 From: Mladen Mihajlovic [mailto:[EMAIL PROTECTED] 
 Sent: 10 October 2005 19:11
 To: log4net-user@logging.apache.org
 Subject: DefaultDomain / Repository Question
 
 Hi,
 
 What would be considered the equal of the following line in 1.2.9?
 
 [assembly: log4net.Config.Domain(UseDefaultDomain=true)]
 
 Thanks,
 Mladen
 
 


RE: TypeInitializationException was unhandled

2005-10-07 Thread Nicko Cadell
What type of application are you building? From the look of the call
stack it looks like some kind of VS add-in. If so which version of VS?
I can't reproduce this with a simple forms app so it may be some
interaction with the hosting process.

Is it possible for you to post the source to a bare bones version of
your app? Just something that it launched in the same way, has a form
which is displayed, and calls XmlConfigurator.Configure from the OnLoad
method. If I can reproduce the problem it is much easier to fix.

Cheers,
Nicko

 -Original Message-
 From: depsi programmer [mailto:[EMAIL PROTECTED] 
 Sent: 04 October 2005 05:40
 To: Log4NET User
 Subject: TypeInitializationException was unhandled
 
 Hi
 
 I am getting following error in log4.net
 
 The exact error message and stack trace:
 
 System.TypeInitializationException was unhandled
 
  Message=The type initializer for
 'log4net.Core.LoggerManager' threw an exception.
 
  Source=log4net
 
  TypeName=log4net.Core.LoggerManager
 
  StackTrace:
 
   at
 log4net.Core.LoggerManager.GetRepository(Assembly
 repositoryAssembly)
 
   at log4net.LogManager.GetRepository(Assembly
 repositoryAssembly)
 
   at log4net.Config.XmlConfigurator.Configure()
  
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
 
   at System.Windows.Forms.Form.OnCreateControl()
 
   at
 System.Windows.Forms.Control.CreateControl(Boolean
 fIgnoreVisible)
 
   at System.Windows.Forms.Control.CreateControl()
 
   at
 System.Windows.Forms.Control.WmShowWindow(Message m)
 
   at System.Windows.Forms.Control.WndProc(Message
 m)
 
   at
 System.Windows.Forms.ScrollableControl.WndProc(Message
 m)
 
   at
 System.Windows.Forms.ContainerControl.WndProc(Message
 m)
 
   at
 System.Windows.Forms.Form.WmShowWindow(Message m)
 
   at System.Windows.Forms.Form.WndProc(Message m)
 
   at
 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message
 m)
 
   at
 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message
 m)
 
   at
 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
 hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
   at
 System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
 hWnd, Int32 msg, Int32 wParam, Int32 lParam)
 
   at
 System.Windows.Forms.Form.SetVisibleCore(Boolean
 value)
 
   at
 System.Windows.Forms.Control.set_Visible(Boolean
 value)
 
   at
 System.Windows.Forms.Application.ThreadContext.RunMessageLoopI
 nner(Int32
 reason, ApplicationContext context)
 
   at
 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
 reason, ApplicationContext context)
 
   at System.Windows.Forms.Application.Run(Form
 mainForm)
 
   at System.AppDomain.nExecuteAssembly(Assembly
 assembly, String[] args)
 
   at System.AppDomain.ExecuteAssembly(String
 assemblyFile, Evidence assemblySecurity, String[]
 args)
 
   at
 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
 
   at
 System.Threading.ThreadHelper.ThreadStart_Context(Object
 state)
 
   at
 System.Threading.ExecutionContext.Run(ExecutionContext
 executionContext, ContextCallback callback, Object
 state)
 
   at System.Threading.ThreadHelper.ThreadStart() 
 
 When I checked the inner exception it was 
 
 The inner exception is
 The type initializer for 'log4net.Core.LoggerManager'
 threw an exception.
 Stack Trace is
   at log4net.Core.LoggerManager.GetRepository(Assembly
 repositoryAssembly)
   at log4net.LogManager.GetRepository(Assembly
 repositoryAssembly)
   at log4net.Config.XmlConfigurator.Configure()
   at xyz.FrmMain.Form1_Load(Object sender, EventArgs
 e) in xyz.vb:line 147
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at
 System.Windows.Forms.Control.CreateControl(Boolean
 fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at
 System.Windows.Forms.Control.WmShowWindow(Message m)
   at System.Windows.Forms.Control.WndProc(Message m)
   at
 System.Windows.Forms.ScrollableControl.WndProc(Message
 m)
   at
 System.Windows.Forms.ContainerControl.WndProc(Message
 m)
   at System.Windows.Forms.Form.WmShowWindow(Message
 m)
   at System.Windows.Forms.Form.WndProc(Message m)
   at
 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message
 m)
   at
 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message
 m)
   at
 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
 hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at
 System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
 hWnd, Int32 msg, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean
 value)
   at System.Windows.Forms.Control.set_Visible(Boolean
 value)
   at
 System.Windows.Forms.Application.ThreadContext.RunMessageLoopI
 nner(Int32
 reason, ApplicationContext context)
   at
 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
 

RE: Custom logging level

2005-09-30 Thread Nicko Cadell
There is an example of how to add the TRACE level to log4net in the log4net 
download at:

extensions\net\1.0\log4net.Ext.Trace\cs\src 

Cheers,
Nicko

 -Original Message-
 From: Søren M. Olesen [mailto:[EMAIL PROTECTED] 
 Sent: 29 September 2005 06:50
 To: log4net-user@logging.apache.org
 Subject: Custom logging level
 
 Hi
 
 I been trying to figure out how to make a custum debug level, 
 but haven't succeded yet...anyone who has an example or know 
 where to find an example, that they'd like to share with me
 
 TIA
 
 Søren
 
 
 


RE: Set Appender properties at run time?

2005-09-28 Thread Nicko Cadell
Jon,

If you mean that you want to change the properties on your MsmqAppender
that you have already configured then you can do something like this:

foreach(log4net.Appender.IAppender appender in
log4net.LogManager.GetRepository().GetAppenders())
{
  // Look for the appender you want to change.
  if (appender is MsmqAppender)
  {
MsmqAppender myAppender = (MsmqAppender)appender;

// Change value of properties
myAppender.QueueName = xxx;
myAppender.ActivateOptions();
  }
} 

Cheers,
Nicko

 -Original Message-
 From: Jon Finley [mailto:[EMAIL PROTECTED] 
 Sent: 16 September 2005 13:42
 To: 'Log4NET User'
 Subject: Set Appender properties at run time?
 
 Hi all,
  
 I have an MsmqAppender and would like to set the queueName 
 property (to which the message should be sent) at runtime.  
 Google turns up a few links that indicate that this is 
 possible (generically).  Does anyone have a code snipped that 
 does something like this that you would be willing to share 
 or point me to a link/sample?
  
 Thanks much!
  
 Jon
 


RE: SmtpAppender buffer flush (to mail) on shutdown.

2005-09-28 Thread Nicko Cadell
Adam,

If the SmtpAppender is configured not to be lossy (i.e. Lossy=false)
then the current buffer will be sent. If the appender is in lossy mode
(Lossy=true) then the buffer is not sent when the appender is closed.

As you are not seeing this behaviour, which version of log4net are you
using?

Cheers,
Nicko

 -Original Message-
 From: Adam Jack [mailto:[EMAIL PROTECTED] 
 Sent: 24 September 2005 16:15
 To: log4net-user@logging.apache.org
 Subject: RE: SmtpAppender buffer flush (to mail) on shutdown.
 
 I've experienced this even with lossy=true, so I don't 
 believe this is the issues.  Anybody have any insights into 
 how I might stop this buffer flush to mail?
 
  
 
 Regards,
 
  
 
 Adam
 
 
 
 From: Adam Jack
 Sent: Tuesday, September 20, 2005 8:29 PM
 To: 'log4net-user@logging.apache.org'
 Subject: SmtpAppender buffer flush (to mail) on shutdown.
 
  
 
 Howdy folks,
 
  
 
 I hope this isn't an FAQ, but I couldn't find the answer in 
 mailing list archives or in the documentation. 
 
  
 
 I have an SmtpAppender pretty much configured as in the example:
 
  
 
  
 http://logging.apache.org/log4net/release/config-examples.html
 #smtpappender
 
  
 
 It is running inside my webapp (configured in the web.config) 
 and works wonderfully, e-mailing me when I get a page 
 crash/error event. 
 
  
 
 The only bummer is sometimes it e-mails me when nothing is 
 wrong, but the webapp has timed out (and is being torn down.) 
 The buffer of non-error log message is sent to me. I've 
 attached the config below, and looking at it I see lossy set 
 to false - which is a worry, I'll set it true again - but I'm 
 pretty certain I only tinkered with that setting when this 
 started happening. Of course, I was preparing this e-mail as 
 I found that setting. 
 
  
 
 Time will tell if this fixes the problem, but I'd really 
 appreciate insights. Is this a designed in feature, or an 
 unintentional side effect? If intentional can I disable it 
 with some (say) disable statement when I capture the shutdown event?
 
  
 
 Thanks for insights, and thanks for this product on this platform.
 
  
 
 Regards
 
  
 
 Adam
 
 --
 
 Adventure Central
 
 http://www.AdventureCentral.com
 
 Great Experiences Deserve Great Technology
 
 303 292 5522 x111
 
 Denver, CO USA
 
  
 
  
 
 
 
 appender name=SmtpAppender 
 type=log4net.Appender.SmtpAppender,log4net
 
 to 
 value=[EMAIL PROTECTED] /
 
 from 
 value=[EMAIL PROTECTED] /
 
 subject 
 value=AdventureWeb Logging. /
 
 bufferSize value=512 /
 
 lossy value=false /
 
 evaluator 
 type=log4net.Core.LevelEvaluator,log4net
 
 threshold 
 value=ERROR /
 
 /evaluator
 
 layout 
 type=log4net.Layout.PatternLayout,log4net
 
 
 conversionPattern value=%property{log4net:HostName} :: 
 %level :: %message %newlineLogger: %logger%newlineThread: 
 %thread%newlineDate: %date%newlineNDC: 
 %property{NDC}%newline%newline /
 
 /layout
 
 /appender
 
 


RE: SmtpAppender buffer flush (to mail) on shutdown.

2005-09-28 Thread Nicko Cadell
1.2.9 should be the right version to use. Let us know if you see the
issue again.

Cheers,
Nicko 

 -Original Message-
 From: Adam Jack [mailto:[EMAIL PROTECTED] 
 Sent: 28 September 2005 16:40
 To: Log4NET User
 Subject: RE: SmtpAppender buffer flush (to mail) on shutdown.
 
 I am using 1.2.9 (release from Apache Incubator.) Could it be 
 that this is too 'old'? 
 
 If not, then I'll triple check that what I last saw didn't 
 have lossy somehow set. Maybe it was a residual message from 
 that configuration, since I've not noticed one recently. 
 Sorry if this was all lossy
 related.
 
 Thanks for investigating.
 
 Regards,
 
 Adam
 -Original Message-
 From: Nicko Cadell [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 28, 2005 7:50 AM
 To: Log4NET User
 Subject: RE: SmtpAppender buffer flush (to mail) on shutdown.
 
 Adam,
 
 If the SmtpAppender is configured not to be lossy (i.e. 
 Lossy=false) then the current buffer will be sent. If the 
 appender is in lossy mode
 (Lossy=true) then the buffer is not sent when the appender is closed.
 
 As you are not seeing this behaviour, which version of 
 log4net are you using?
 
 Cheers,
 Nicko
 
  -Original Message-
  From: Adam Jack [mailto:[EMAIL PROTECTED]
  Sent: 24 September 2005 16:15
  To: log4net-user@logging.apache.org
  Subject: RE: SmtpAppender buffer flush (to mail) on shutdown.
  
  I've experienced this even with lossy=true, so I don't 
 believe this 
  is the issues.  Anybody have any insights into how I might 
 stop this 
  buffer flush to mail?
  
   
  
  Regards,
  
   
  
  Adam
  
  
  
  From: Adam Jack
  Sent: Tuesday, September 20, 2005 8:29 PM
  To: 'log4net-user@logging.apache.org'
  Subject: SmtpAppender buffer flush (to mail) on shutdown.
  
   
  
  Howdy folks,
  
   
  
  I hope this isn't an FAQ, but I couldn't find the answer in mailing 
  list archives or in the documentation.
  
   
  
  I have an SmtpAppender pretty much configured as in the example:
  
   
  
   
  http://logging.apache.org/log4net/release/config-examples.html
  #smtpappender
  
   
  
  It is running inside my webapp (configured in the web.config) and 
  works wonderfully, e-mailing me when I get a page crash/error event.
  
   
  
  The only bummer is sometimes it e-mails me when nothing is 
  wrong, but the webapp has timed out (and is being torn down.) 
  The buffer of non-error log message is sent to me. I've 
  attached the config below, and looking at it I see lossy set 
  to false - which is a worry, I'll set it true again - but I'm 
  pretty certain I only tinkered with that setting when this 
  started happening. Of course, I was preparing this e-mail as 
  I found that setting. 
  
   
  
  Time will tell if this fixes the problem, but I'd really 
  appreciate insights. Is this a designed in feature, or an 
  unintentional side effect? If intentional can I disable it 
  with some (say) disable statement when I capture the shutdown event?
  
   
  
  Thanks for insights, and thanks for this product on this platform.
  
   
  
  Regards
  
   
  
  Adam
  
  --
  
  Adventure Central
  
  http://www.AdventureCentral.com
  
  Great Experiences Deserve Great Technology
  
  303 292 5522 x111
  
  Denver, CO USA
  
   
  
   
  
  
  
  appender name=SmtpAppender 
  type=log4net.Appender.SmtpAppender,log4net
  
  to 
  value=[EMAIL PROTECTED] /
  
  from 
  value=[EMAIL PROTECTED] /
  
  subject 
  value=AdventureWeb Logging. /
  
  bufferSize value=512 /
  
  lossy value=false /
  
  evaluator 
  type=log4net.Core.LevelEvaluator,log4net
  
  threshold 
  value=ERROR /
  
  /evaluator
  
  layout 
  type=log4net.Layout.PatternLayout,log4net
  
  
  conversionPattern value=%property{log4net:HostName} :: 
  %level :: %message %newlineLogger: %logger%newlineThread: 
  %thread%newlineDate: %date%newlineNDC: 
  %property{NDC}%newline%newline /
  
  /layout
  
  /appender
  
  
 
 
 


RE: How to pass integrated security credentials to AdoNetAppender from ASP.NET?

2005-09-28 Thread Nicko Cadell
By default the SqlConnection will use the credentials of the current
user (from the process token or if the thread is impersonating from the
thread token). This is the equivalent of
System.Net.CredentialCache.DefaultCredentials.

As the AdoNetAppender tries to open the SqlConnection during
ActivateOptions the credentials will depend on the thread used to
configure the appender.

If you are loading the configuration file in your ASP.NET
Application_Start method then you need to be aware of the security token
held by the thread running this method. This depends on how you are
hosting ASP.NET. If you are using IIS5 then this will be running as the
local user ASPNET. Under IIS6 the user depends on how you have setup the
Identity section of the relevant application pool.

Do your web users use integrated authentication to authenticate with
your web application? Do you have identity impersonate=true / set in
your Web.config file? If so then that explains why your users are able
to open connections to the database.

If you want to use integrated authentication for your web application
(rather than a specific user that is using your application) to talk to
the database then you need to make the ASP.NET application run under a
windows account that has permission to connect to your database. There
are various ways of doing this depending on your environment, these are
well covered in the MS documentation.

The SecurityContext property on appenders allows the thread token to be
overridden for the appenders activities. If you cannot allow the Web
application to access the database by changing the identity it runs as,
and you cannot use sql user logins (sql server in mixed authentication
mode) then you can use a SecurityContext to do this.

To set the SecurityContext in the config file to use windows integrated
authentication use: 

appender name=AdoNetAppender type=log4net.Appender.AdoNetAppender

  securityContext type=log4net.Util.WindowsSecurityContext
userName value=test1 /
password value=password /
domain value=domain /
  /securityContext

  ... other properties here ...
/appender

From a security point of view this is no better or worse than specifying
the sql user id and password in the connection string.

Cheers,
Nicko

 -Original Message-
 From: Billy Barnum [mailto:[EMAIL PROTECTED] 
 Sent: 22 September 2005 18:48
 To: log4net-user@logging.apache.org
 Subject: How to pass integrated security credentials to 
 AdoNetAppender from ASP.NET?
 
 I'm successfully logging to a SQL Server table using stored 
 procs and my own context information - the whole 9 yards. 
 Works great with SQL Server security; chokes with 'integrated 
 security=SSPI', etc. I get the following error msg:
 
 log4net:ERROR [AdoNetAppender] Could not open database 
 connection [workstation id=BBARNUMXP;packet 
 size=4096;integrated security=SSPI;data 
 source=BMT2;persist security info=False;initial catalog=WIAN]
 System.Data.SqlClient.SqlException: Login failed for user 
 '(null)'. Reason:
 Not associated with a trusted SQL Server connection.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean
 isInTransaction)
at
 System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnec
 tion(SqlConnec
 tionString options, Boolean isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at log4net.Appender.AdoNetAppender.InitializeDatabaseConnection()
 
 I know I'm otherwise setting up correctly, because I can 
 successfully invoke the same stored proc using the same 
 connection string through standard ADO.NET SqlDataAdapter, 
 DataSet, and Connection objects. I connect, no prob.
 
 So I looked in the SDK docs and found WindowsSecurityContext 
 and tried to set the AdoNetAppender.SecurityContext property, 
 but no dice. My
 Application_Start() code is below, and I've tried varying the 
 order of events as well, all to no avail; same error. Also 2 
 other questions: (1) How would I pass in the equivalent of 
 System.Net.CredentialCache.DefaultCredentials instead of 
 hard-coding uid/pwd (especially password!) ? (2) Note I pass 
 a null to Impersonate(). Couldn't figure out what I was 
 supposed to do there. Could this be the problem?
 
 I'm not very good with security issues; anyone got any ideas? 
 Thanks in advance.
 
 -BillyB
 William Barnum
 [EMAIL PROTECTED]
 
 P.S. I'm surprised no one has ever asked this question 
 before. You'd think this would come up often; none of my 
 clients have ever used anything but integrated security. 
 Anyway, I searched everywhere, so if the answer is previously 
 posted, my abject apologies.
  
 protected void Application_Start(Object sender, EventArgs e) {
   log4net.Util.WindowsSecurityContext log4NetSecurityContext = 
   new log4net.Util.WindowsSecurityContext();
   log4NetSecurityContext.DomainName = BMT;
   log4NetSecurityContext.UserName = SQL_USER;
   log4NetSecurityContext.Password = abcef;
   

RE: Including datetime stamp in the log messages.

2005-09-19 Thread Nicko Cadell
Which version of log4net are you using?

What does the output of your FileAppender look like at the moment?

In your desired output example you have a chunk in square brackets (e.g.
[120048]) between the date and the level name, what do you want here?
Thread ID?

From your example is Void WriteToLog_Info(System.String) part of your
log message text?


Cheers,
Nicko

 -Original Message-
 From: Ramaa Davanagere [mailto:[EMAIL PROTECTED] 
 Sent: 19 September 2005 13:56
 To: 'log4net-user@logging.apache.org'
 Subject: Including datetime stamp in the log messages.
 
  
 
 I'm using a fileappender and logging messages to a text file.
 
  
 
 My Fileappender and PatternLayout are set like this...
 
  
 
 log4net.Appender.FileAppender oFileAppender = new 
 log4net.Appender.FileAppender();
 
 log4net.Layout.PatternLayout oPatternLayout = new 
 log4net.Layout.PatternLayout();
 
 oPatternLayout.Header = [Begin]\r\n;
 
 oPatternLayout.Footer = [End]\r\n\r\n;
 
 oPatternLayout.ConversionPattern = %d %-5p %c %m%n;
 
  
 
 But I want the output to look like the sample shown below. I 
 want to include the datetime stamp for each message that is 
 logged to the text file followed by the message type 
 constants (debug, error, fatal, info, etc) and then my log message. 
 
  
 
 2005-08-30 08:56:27,968[120048]INFO  
 MyCompanyName.MyProductName.ErrorHandler - Void 
 WriteToLog_Info(System.String) about to write a log message
 
 2005-08-30 08:57:58,890[129088]ERROR 
 MyCompanyName.MyProductName.ErrorHandler - Void 
 WriteToLog_Err(System.String): Object variable not set
 
  
 
 Can somebody look at my conversionPattern string and let me 
 know what is wrong?
 
  
 
 Thanks.
 
  
 
 


  1   2   3   4   >