[jira] Updated: (LOG4NET-73) ADONetAppender.ActivateOptions() leaks database connection when called multiple times

2006-03-27 Thread Nicko Cadell (JIRA)
 [ http://issues.apache.org/jira/browse/LOG4NET-73?page=all ]

Nicko Cadell updated LOG4NET-73:


Summary: ADONetAppender.ActivateOptions() leaks database connection when 
called multiple times  (was: ADONetAppender.ActivateOptions() database 
Connection Leak is called multiple times)

> ADONetAppender.ActivateOptions() leaks database connection when called 
> multiple times
> -
>
>  Key: LOG4NET-73
>  URL: http://issues.apache.org/jira/browse/LOG4NET-73
>  Project: Log4net
> Type: Bug
>   Components: Appenders
> Versions: 1.2.9
> Reporter: Nicko Cadell
> Assignee: Nicko Cadell

>
> ADONetAppender.ActivateOptions() calls InitializeDatabaseConnection. This 
> method does not check if the m_dbConnection is already initialised. If it is 
> initialise then it will beleaked.
> Update InitializeDatabaseConnection to check and close the connection if not 
> null.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



[jira] Resolved: (LOG4NET-73) ADONetAppender.ActivateOptions() leaks database connection when called multiple times

2006-03-27 Thread Nicko Cadell (JIRA)
 [ http://issues.apache.org/jira/browse/LOG4NET-73?page=all ]
 
Nicko Cadell resolved LOG4NET-73:
-

Fix Version: 1.2.10
 Resolution: Fixed

Added code to cleanup the connection and command members if the 
InitialiseDatabaseConnection method is called multiple times.

> ADONetAppender.ActivateOptions() leaks database connection when called 
> multiple times
> -
>
>  Key: LOG4NET-73
>  URL: http://issues.apache.org/jira/browse/LOG4NET-73
>  Project: Log4net
> Type: Bug
>   Components: Appenders
> Versions: 1.2.9
> Reporter: Nicko Cadell
> Assignee: Nicko Cadell
>  Fix For: 1.2.10

>
> ADONetAppender.ActivateOptions() calls InitializeDatabaseConnection. This 
> method does not check if the m_dbConnection is already initialised. If it is 
> initialise then it will beleaked.
> Update InitializeDatabaseConnection to check and close the connection if not 
> null.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



svn commit: r389130 - /logging/log4net/trunk/src/Appender/AdoNetAppender.cs

2006-03-27 Thread nicko
Author: nicko
Date: Mon Mar 27 04:57:23 2006
New Revision: 389130

URL: http://svn.apache.org/viewcvs?rev=389130&view=rev
Log:
Fix for LOG4NET-73. Added code to cleanup the connection and command objects 
that are stored in members if the InitializeDatabaseConnection method is called 
multiple times.

Modified:
logging/log4net/trunk/src/Appender/AdoNetAppender.cs

Modified: logging/log4net/trunk/src/Appender/AdoNetAppender.cs
URL: 
http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Appender/AdoNetAppender.cs?rev=389130&r1=389129&r2=389130&view=diff
==
--- logging/log4net/trunk/src/Appender/AdoNetAppender.cs (original)
+++ logging/log4net/trunk/src/Appender/AdoNetAppender.cs Mon Mar 27 04:57:23 
2006
@@ -407,14 +407,30 @@
override protected void OnClose() 
{
base.OnClose();
+
+   // Close the cached command and connection objects
if (m_dbCommand != null)
{
-   m_dbCommand.Dispose();
+   try
+   {
+   m_dbCommand.Dispose();
+   }
+   catch (Exception ex)
+   {
+   LogLog.Warn("AdoNetAppender: Exception 
while disposing cached command object", ex);
+   }
m_dbCommand = null;
}
if (m_dbConnection != null)
{
-   m_dbConnection.Close();
+   try
+   {
+   m_dbConnection.Close();
+   }
+   catch (Exception ex)
+   {
+   LogLog.Warn("AdoNetAppender: Exception 
while disposing cached connection object", ex);
+   }
m_dbConnection = null;
}
}
@@ -607,6 +623,32 @@
{
try
{
+   // Cleanup any existing command or connection
+   if (m_dbCommand != null)
+   {
+   try
+   {
+   m_dbCommand.Dispose();
+   }
+   catch (Exception ex)
+   {
+   LogLog.Warn("AdoNetAppender: 
Exception while disposing cached command object", ex);
+   }
+   m_dbCommand = null;
+   }
+   if (m_dbConnection != null)
+   {
+   try
+   {
+   m_dbConnection.Close();
+   }
+   catch (Exception ex)
+   {
+   LogLog.Warn("AdoNetAppender: 
Exception while disposing cached connection object", ex);
+   }
+   m_dbConnection = null;
+   }
+
// Create the connection object
m_dbConnection = 
(IDbConnection)Activator.CreateInstance(ResolveConnectionType());

@@ -665,6 +707,20 @@
{
try
{
+   // Cleanup any existing command or 
connection
+   if (m_dbCommand != null)
+   {
+   try
+   {
+   m_dbCommand.Dispose();
+   }
+   catch (Exception ex)
+   {
+   
LogLog.Warn("AdoNetAppender: Exception while disposing cached command object", 
ex);
+   }
+   m_dbCommand = null;
+   }
+
// Create

svn commit: r389152 - in /logging/log4net/trunk: src/ src/Core/ src/Util/ tests/ tests/lib/ tests/src/ tests/src/Core/

2006-03-27 Thread nicko
Author: nicko
Date: Mon Mar 27 06:10:19 2006
New Revision: 389152

URL: http://svn.apache.org/viewcvs?rev=389152&view=rev
Log:
Fix for LOG4NET-72. Moved String.Format call into separate class 
SystemStringFormat. This class holds the format string and arguments and only 
performs the String.Format when its ToString method is called.
Added simple test to ensure that the String.Format methods are working 
correctly and error handling correctly.
Updated the tests project nant.build to copy shared libs into the build output 
directory.

Added:
logging/log4net/trunk/src/Util/SystemStringFormat.cs
logging/log4net/trunk/tests/lib/
logging/log4net/trunk/tests/lib/prerequisites.txt
logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
Modified:
logging/log4net/trunk/src/Core/LogImpl.cs
logging/log4net/trunk/src/Util/Transform.cs
logging/log4net/trunk/src/log4net.csproj
logging/log4net/trunk/tests/nant.build
logging/log4net/trunk/tests/src/log4net.Tests.csproj

Modified: logging/log4net/trunk/src/Core/LogImpl.cs
URL: 
http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Core/LogImpl.cs?rev=389152&r1=389151&r2=389152&view=diff
==
--- logging/log4net/trunk/src/Core/LogImpl.cs (original)
+++ logging/log4net/trunk/src/Core/LogImpl.cs Mon Mar 27 06:10:19 2006
@@ -216,7 +216,7 @@
{
if (IsDebugEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelDebug, 
Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelDebug, new 
SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
 
@@ -242,7 +242,7 @@
{
if (IsDebugEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelDebug, 
Transform.StringFormat(provider, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelDebug, new 
SystemStringFormat(provider, format, args), null);
}
}
 
@@ -321,7 +321,7 @@
{
if (IsInfoEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelInfo, 
Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelInfo, new 
SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
 
@@ -347,7 +347,7 @@
{
if (IsInfoEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelInfo, 
Transform.StringFormat(provider, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelInfo, new 
SystemStringFormat(provider, format, args), null);
}
}
 
@@ -426,7 +426,7 @@
{
if (IsWarnEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelWarn, 
Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelWarn, new 
SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
 
@@ -452,7 +452,7 @@
{
if (IsWarnEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelWarn, 
Transform.StringFormat(provider, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelWarn, new 
SystemStringFormat(provider, format, args), null);
}
}
 
@@ -531,7 +531,7 @@
{
if (IsErrorEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelError, 
Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelError, new 
SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
 
@@ -557,7 +557,7 @@
{
if (IsErrorEnabled)
{
-   Logger.Log(ThisDeclaringType, m_levelError, 
Transform.StringFormat(provider, format, args), null);
+   Logger.Log(ThisDeclaringType, m_levelError, new 
SystemStringFormat(provider, format, args), null);
}
}
 
@@ -636,7 +636,7 @@
{
if (IsFatalEnabled)
{
-   

[jira] Resolved: (LOG4NET-70) CoreDll.dll referenced with different capitalisation

2006-03-27 Thread Nicko Cadell (JIRA)
 [ http://issues.apache.org/jira/browse/LOG4NET-70?page=all ]
 
Nicko Cadell resolved LOG4NET-70:
-

Resolution: Fixed

Check in to update referenced dll name has fixed this issue.

> CoreDll.dll referenced with different capitalisation
> 
>
>  Key: LOG4NET-70
>  URL: http://issues.apache.org/jira/browse/LOG4NET-70
>  Project: Log4net
> Type: Bug
>   Components: Core
> Versions: 1.2.9
> Reporter: Nicko Cadell
> Assignee: Nicko Cadell
> Priority: Trivial
>  Fix For: 1.2.10

>
> The CoreDll.dll is referenced as both CoreDll.dll and coredll.dll. This has 
> no effect on functionality but we should be consistant and use CoreDll.dll.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



RE: Is this a bug?

2006-03-27 Thread Nicko Cadell
This is by design, but it is subtle behaviour.
The configuration attributes are loaded from the first assembly to call
log4net.LogManager.GetLogger. Configuration attributes on other
assemblies loaded into the process are ignored. What this basically
means is that you main assembly should get a logger before loading any
library code (including references to types). The easier way to do this
is to define a static log variable on you entry point class. It is
usually good practice to log a message as early as possible in the
application lifecycle to record the start time etc.

Nicko

> -Original Message-
> From: Morten Andersen [mailto:[EMAIL PROTECTED] 
> Sent: 28 January 2006 14:32
> To: log4net-dev@logging.apache.org
> Subject: Is this a bug?
> 
> Create a solution with a windows application, and a class 
> library. Add a project reference to to the class library, and 
> a reference to the log4net.dll
> 
> If you run the application now, you should see something like
> "2006-01-28 15:18:04,556 [3028] INFO  BugApplication.MyClass 
> [(null)] - Hello world" in the output window.
> 
> As you can see there are three lines that are comments. One 
> in Program.cs and two in Class1.cs
> 
> If you uncomment the log line in Class1.cs, you will not see 
> any output if you try to run the application.
> 
> Now there is two different solutions to make the logging work 
> again. You can uncomment the log line in Program.cs, or you 
> can uncomment the assembly line in Class1.cs
> 
> 
> ===
> Windows Application (Program.cs)
> ===
> 
> [assembly: log4net.Config.XmlConfigurator(Watch = true)] 
> namespace BugApplication {
> static class Program
> {
> //static readonly log4net.ILog log = 
> log4net.LogManager.GetLogger(typeof(Program));
> 
> static void Main()
> {
> BugClassLibrary.MyLibClass.Start(typeof(MyClass));
> }
> }
> 
> class MyClass : BugClassLibrary.MyInterface
> {
> static readonly log4net.ILog log = 
> log4net.LogManager.GetLogger(typeof(MyClass));
> 
> public void Start()
> {
> log.Info("Hello world");
> }
> }
> }
> 
> ===
> Windows Applicaton (App.config)
> ===
> 
> 
> 
> 
>  type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
> 
> 
>  type="log4net.Appender.ConsoleAppender" >
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ===
> Class Library (Class1.cs)
> ===
> 
> //[assembly: log4net.Config.XmlConfigurator(Watch = true)] 
> namespace BugClassLibrary {
> public interface MyInterface
> {
> void Start();
> }
> 
> public class MyLibClass
> {
> //static readonly log4net.ILog log = 
> log4net.LogManager.GetLogger(typeof(MyLibClass));
> 
> public static void Start(System.Type type)
> {
> 
> ((MyInterface)System.Activator.CreateInstance(type)).Start();
> }
> }
> }
> 
> ===
> 
> 


[jira] Resolved: (LOG4NET-69) Exception thrown when *Format methods are given a malformed format string

2006-03-27 Thread Nicko Cadell (JIRA)
 [ http://issues.apache.org/jira/browse/LOG4NET-69?page=all ]
 
Nicko Cadell resolved LOG4NET-69:
-

Fix Version: 1.2.10
 Resolution: Fixed

This is fixed and i have added a test to ensure that malformed format strings 
don't leak exceptions.

> Exception thrown when *Format methods are given a malformed format string
> -
>
>  Key: LOG4NET-69
>  URL: http://issues.apache.org/jira/browse/LOG4NET-69
>  Project: Log4net
> Type: Bug
> Versions: 1.2.9
> Reporter: Ron Grabowski
> Assignee: Nicko Cadell
> Priority: Critical
>  Fix For: 1.2.10

>
> FormatException thrown when *Format methods are given a malformed format 
> string: log.DebugFormat("Malformed {{,,,5}format{8}!");
> This statement:
>  log.DebugFormat("Malformed {{,,,5}format{8}!");
> throws the following exception:
> [FormatException: Input string was not in a correct format.]
>System.Text.StringBuilder.FormatError()
>System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String 
> format, Object[] args)
>System.String.Format(IFormatProvider provider, String format, Object[] 
> args)
>log4net.Core.LogImpl.DebugFormat(String format, Object[] args)
> which is consistent with the documentation for String.Format:
> System.FormatException: The format item in format is invalid.  -or- The 
> number indicating an argument to format is less than zero, or greater than or 
> equal to the number of specified objects to format.  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



[jira] Created: (LOG4NET-74) Change MemoryAppender member variables to protected

2006-03-27 Thread Nicko Cadell (JIRA)
Change MemoryAppender member variables to protected
---

 Key: LOG4NET-74
 URL: http://issues.apache.org/jira/browse/LOG4NET-74
 Project: Log4net
Type: Improvement
  Components: Appenders  
Versions: 1.2.9
Reporter: Nicko Cadell
 Assigned to: Nicko Cadell 
Priority: Trivial


The MemoryAppender is designed to hold the log events in an internal array. The 
appender can be subclassed, however the internal list is not available to 
subclasses.
This appender will be more useful if the members are protected.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira